Book -- or website -- about Tk & tkinter
bowman at montana.com
Sat Aug 21 19:43:39 CEST 1999
Phil Hunt wrote:
> Is the Lif Preserver still useful? Lundh's _An Introduction to
> Tkinter_ says it's a replacement for it.
I use a local copy of LifePreserver as a quick reference, and have a
Netscape button aimed at it. I have the Intro as a ps file, but
ghostview doesn't really make my day.
I'm sure Lundh work will be a replacement someday, but that is then...
Right now, it seems the areas I'm interested in are largely TODOs.
Menus, for instance.
> But you're right -- experimentation will no doubt be necessary.
I'm mostly faking it, working from Tcl/Tk, PerlTk, Motif, X docs, and
prior experience with Java and MS Windows programming in C. Essentially,
I'm trying to develop a Tkinter style that is consistent with what I do
in other languages. This sometimes leads me to interesting (to me)
tricks. I'm used to using pretty much anonymous widgets, and determining
their identity in the callbacks, leading to hacks like:
for b in ('one', 'two', 'three'):
b = Button(parent, text=b)
b['command'] = lambda wid=b : (someFunc(wid))
Its real easy to whip up a Tkinter GUI for a specific set of widgets,
which is what most of the examples do. Trying to use another level of
generalization, say if you want to generate a GUI from something like a
uil or rc file, or in your case, Parrot, requires a little more work.
> Ah yes, Java's GridBagLayout widget.
Yeah, wondrous thing, that. In Java, I tend to set the layout manager to
null and do absolute positioning. Or, I should say, I calculate the
positions and then place things, effectively writing my own manager.
Moot point. It gets ugly, especially with text, where you need to get
the TextMetrics, or whatever the local Java/Windows/Xt word for it is.
There is no free lunch, though, and someplace, somewhere, somebody is
doing the math. At least if you do it yourself, there are no surprises
-- or you can fix your own little surprises.
You might want to take a look at place(), too. The relative positioning
isn't real intuitive, but it sometimes helps to place a widget at 33% of
the width of the parent, no matter what happens to the parent.
Bear Technology Making Montana safe for Grizzlies
More information about the Python-list