[Tutor] Tkinter

Adam Vardy Adam Vardy <anvardy@roadrunner.nf.net>
Mon Jan 6 13:58:02 2003


Friday, January 3, 2003, 7:22:25 PM, you wrote:

>>
>> 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?

Specifically from a command prompt:

=============================================================

from Tkinter import *
import time,msvcrt

root = Tk()
c = Canvas(root)
c.pack()

o = c.create_text(35,35,text="Hi!")

root.update()

for i in range (1,10):
   c.move(o,8*i,0)
   root.update()
   a=msvcrt.getch()



>> Most IDEs have their own event loop that doesn't
>> play nice with Tkinter.

>>

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

How then do you send an argument to the function?  And where was it
said that you could just type the name, and no () which always seem
mandatory?


-- 
Adam Vardy