469,306 Members | 2,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Idiots guide to fonts with tKinter

Hi all,

I'm a programming dabbler trying learn Python, and I've got a few
questions.

Mainly: Where can I find a good open-source library or tutorial
(preferably free) that explains how to easily manipulate text in a
tKinter window? Basically, I want to be able to do anything that HTML
can do (or close to it) but without the HTML. :-)

My "newbie dream project" is to piece together a functional, WYSIWYG
text editor that can handle at least three fonts: Times New Roman,
Arial and Courier (bold, italics and underlined).

I know, I know. That's pretty ambitious. But that's my goal for Python.
So....what's the easiest way to get there? What steps should I take?
I'm not in any rush, I just want some help along the way...

Aug 4 '05 #1
2 2326
Well, all text classes in Tkinter can take a " font=(...) " argument to
specify the face with which to display, for example:

from tkinter import *
.....
label = Label(root, font=("Helvetica", "bold", 13), ...)
It's been a while since I've played with Tkinter, so I might be a
little off on the exact syntax, but that's the main idea. It's really
simple once you get the hang of it.

Regarding the text editor: it's an excellent idea. By using Tkinter's
text widget you can get a bit of milage easily; you'll have to define
and use "tags" in order to organize your text styles, it'll make
everything quite a bit easier.

You can glean a bunch of info from Idle's sources.

Good luck :-)

-gus

Aug 5 '05 #2
No doubt you have found Fredrik Lundh's intro:

http://www.pythonware.com/library/tkinter/introduction/

You can get a long way with that and experimenting.

Also, check out Tk:

http://www.astro.princeton.edu/~rhl/.../contents.html

If you can figure out how to translate the Tk documentation into Tkinter, you
open a lot of doors for yourself.

The best easily available Tkinter tutorial I have found is in the Programming
Python book by Mark Lutz (O'Reilly):

http://www.oreilly.com/catalog/python2/toc.html

Its $55 bucks, but is full of good examples, so it is worth it. The price of
course is not the money, but the fact that some parts of the book (not
necessarily the Tkinter part) can get pretty tedious to work through. But its
worth the investment in time and money. I don't recommend learning Tkinter
with just a reference manual (like Lundh's page).

You'll waste far more money's worth of time than just $55 trying to figure out
how to do things that are already clearly described in Programming Python.

James

On Thursday 04 August 2005 02:02 am, import newbie wrote:
Hi all,

I'm a programming dabbler trying learn Python, and I've got a few
questions.

Mainly: Where can I find a good open-source library or tutorial
(preferably free) that explains how to easily manipulate text in a
tKinter window? Basically, I want to be able to do anything that HTML
can do (or close to it) but without the HTML. :-)

My "newbie dream project" is to piece together a functional, WYSIWYG
text editor that can handle at least three fonts: Times New Roman,
Arial and Courier (bold, italics and underlined).

I know, I know. That's pretty ambitious. But that's my goal for Python.
So....what's the easiest way to get there? What steps should I take?
I'm not in any rush, I just want some help along the way...


--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
Aug 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by phil | last post: by
reply views Thread by syed_saqib_ali | last post: by
9 posts views Thread by Jay | last post: by
1 post views Thread by Michael Yanowitz | last post: by
reply views Thread by Unnamed One | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.