[Tutor] Tinkering with Tkinter

Doug Reid rnrcreid at yahoo.com
Tue May 26 02:45:39 CEST 2009


The following code and it's explanation doesn't seem to work:
 
1. >>> from Tkinter import *
2. >>> tk = Tk()
3. >>> btn = Button(tk, text="click me")
4. >>> btn.pack()
 
In line 1, we import the contents of the Tk module, so we can use them—the
most useful of these is Tk, which creates a basic window to which we can then add
things. After you type in line 2, that window will suddenly appear on the screen.
In line 3, we create a new Button and assign it to the variable btn. The button
is created by passing the tk object as a parameter, along with a named parameter
with the words ‘click me’.
 
Nothing appears on the screen after I enter line 2...I can type in the code in the editor and double click after saving the file and it does, but not from the shell, how can that be fixed or am I doing something wrong?
 
Thanks
 
Doug


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090525/5cb1df91/attachment.htm>


More information about the Tutor mailing list