[Tutor] Tkinter

Don Arnold Don Arnold" <darnold02@sprynet.com
Fri Jan 3 17:54:01 2003


----- Original Message -----
From: "Adam Vardy" <anvardy@roadrunner.nf.net>
To: <tutor@python.org>
Sent: Friday, January 03, 2003 1:45 PM
Subject: [Tutor] Tkinter


>
> Experimenting with TK, I came up on difficulties. Like, in one
> program, the window is there but whenever the pointer is over the
> window, there is always an hourglass.  Can't see anything
> wrong.

I don't know about this one, but does it happen when you execute the script
from the command prompt? Most IDEs have their own event loop that doesn't
play nice with Tkinter.

>
> In another example, I have a button on the window. And a function is
> set to run for that. But it runs right away. And nothing happens when
> I hit the button!
>
> --
> Adam Vardy

This is a pretty common error. Make sure the callback you supply to the
button constructor does _not_ include the parentheses. For example:

b = Button(master, text="OK", command=self.ok)

assigns the function 'self.ok' as the callback to be executed when the
button is pressed. However,


b = Button(master, text="OK", command=self.ok( ) )

executes self.ok( ) once when the button is istantiated and assigns the
result to the button's 'command' attribute.
For more info on Tkinter, you might want to check out
http://www.pythonware.com/library/tkinter/introduction/index.htm .

HTH,
Don