Idiots guide to fonts with tKinter

I

import newbie

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...
 
R

RangerElf

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
 
J

James Stroud

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/Tcl-Tk_docs/tk8.0a1/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

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top