9 Mar 1999 16:25:07 -0500
Content-Type: text/plain; charset=US-ASCII
Then <email@example.com> spoke up and said:
> I need some help with Tkinter, and find the Pythonware tutorial to be =
> lacking. I'd like create a button to call an application and dialog =
> window for input, and present the results. Are there some good examples =
> to look at to get me started?
Firstly, *please* disable sending mail as HTML.
Next, I've always found that the best place to look for doing Tkinter
things is in the DEMO directory of the source distribution.
Unfortunately, there really are no "good" examples.
One trick that sometimes works for me is to design something in
Tcl/Tk, and then translate it into Tkinter. Of course, you end up
working twice as hard, and if you use a tool like SpecTCL, the
translation step can be painful.
Speaking of SpecTCL, there is a plugin for it called SpecPYTHON that
(theoretically) lets you design Tkinter apps and spits out Python
code. Unfortunately, getting it all working is non-trivial.
I almost forgot: don't forget to look at the source in
/usr/local/lib/python1.5/lib-tk/*.py. While somewhat minimal, most of
the source files there include test functions that show small,
low-level uses of the various widgets.
Beyond that, you have to get really specific. The most generic advice
to give is this: Learn how to use and write factory functions. They
are your friends. e.g
def button_factory(master, command=None):
b = Tkinter.Button(t, background='red', command)
t = Tkinter.Toplevel()
t.b1 = button_factory(t, command=foo)
While the above example is *really* trivial, if you have a more
exciting set of attributes that need to be set for every button, the
factory function will become very handy (and even more readable).
Does this answer your question (at least in part)?
| JAVA must have been developed in the wilds of West Virginia. |
| After all, why else would it support only single inheritance?? |
| Finger firstname.lastname@example.org for my public key. |
-----BEGIN PGP MESSAGE-----
Comment: Processed by Mailcrypt 3.3, an Emacs/PGP interface
-----END PGP MESSAGE-----