A Tcl/Tk programmer learns Python--any advice?
Russell E. Owen
rowen at cesmail.net
Tue Nov 8 13:29:04 EST 2005
In article <ef6d2$436f7b11$4275d90a$30783 at FUSE.NET>,
Kevin Walzer <sw at wordtech-software.com> wrote:
>I'm a Tcl/Tk developer who has been dabbling with Python for some time,...
>Well, I have finally found a good reason to learn Python in more depth:...
>
>Any advice, particularly from other programmers with a lot of experience
>in Tcl, is appreciated.
In Tkinter you don't name widgets to specify their hierarchy; instead
when you create a new widget you specify it's parent. A tk name does get
generated for you, but you'll never need it.
You can set and get properties on Tkinter widgets using dictionary
notation:
curr_value = wdg["property_name"]
wdg["property_name"] = new_value
this is very convenient if you don't want to set a lot of properties at
once.
Grid in Tkinter has less useful defaults than in tk. You should probably
specify row and column when using Tkinter's gridder.
If you try to mix tk and Tkinter, beware of Tkinter objects that clean
up after themselves. For instance a tkFont.Font object represents a
named font in tk, but if you lose all references to it in python, the
named font in tk is destroyed.
Features of Python that are well integrated and well worth using include:
- objects
- collection classes (including list, dict and set)
- exception handling
- default arguments for functions
tcl is a unusual in its desire to parse every string as a command. It
has plusses and minuses, but in any case, you'll have to learn to do
without (as you would when switching to almost any other language).
-- Russell
More information about the Python-list
mailing list