[Tutor] Tkinter

Gregor Lingl glingl@aon.at
Tue Jan 7 17:00:28 2003


Appendix:

I'm not sure if this was not already posted few days ago,
nevertheless the following link not only does contain
an intro to Tkinter, but also links to most - if not all -
relevant documents on Tkinter:

http://home.att.net/~stephen_ferg/thinking_in_tkinter/index.html

Regards, Gregor


Adam Vardy schrieb:

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