[Tutor] Tinkering with Tkinter

Doug Reid rnrcreid at yahoo.com
Tue May 26 14:00:34 CEST 2009



--- On Tue, 5/26/09, W W <srilyk at gmail.com> wrote:


From: W W <srilyk at gmail.com>
Subject: Re: [Tutor] Tinkering with Tkinter
To: "Doug Reid" <rnrcreid at yahoo.com>
Cc: Tutor at python.org
Date: Tuesday, May 26, 2009, 11:42 AM


On Mon, May 25, 2009 at 7:45 PM, Doug Reid <rnrcreid at yahoo.com> wrote:






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?

Works for me! 

What is your os/python verision? Are you working from Idle? AFAIK, IDLE is written in Tk and so it does not so much like Tkinter programs in it's interactive shell. If you're on windows, try typing "cmd" in the run dialog and then type "python" at the prompt, then try the example.

HTH,
Wayne
 
+++Thanks for the help.  I tried it from the command line and it worked fine.
 
Doug



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090526/9818cd5a/attachment.htm>


More information about the Tutor mailing list