Please help - Tkinter not doing anything

Scott David Daniels Scott.Daniels at Acm.Org
Sun May 4 19:41:34 EDT 2008


s0suk3 at gmail.com wrote:
> On May 4, 5:22 am, Protected <myshel... at gmail.com> wrote:
>> .... I'm pasting the code in IDLE and using Windows XP....
> 
> Tkinter doesn't work if you type the statements in IDLE.... it doesn't 
 > work because IDLE is itself a Tkinter app.

Actually, _because_ IDLE is a Tkinter app,you can use it to
experiment with Tkinter in a very useful way.  The trick is that
you need to start idle with the "-n" (No subprocesses) switch.
This is so useful that I build a shortcut on my desktop to do exactly
this.  Using this shortcut you can see the effect of each action as
you type it, giving you an idea of exactly what must happen.

I'm assuming you are using Python 2.5 here (other versions have
related recipes, but slightly more complicated).
Right click on the desktop, and choose "New Shortcut."

For "Choose the location of the item", browse to (or type in)
     C:\Python25\pythonw.exe
Then (after your next) pick a name for your shortcut.
Right click on the resulting shortcut, and go to "properties"
Change the "Target" entry from:
     C:\Python25\pythonw.exe
to:
     C:\Python25\pythonw.exe -m idlelib.idle -n
Also, if you are like me, you'll want to change the "Start in" directory
to wherever you work on python code --so imports of your own stuff "just
work", and so "File open'" and "Save As" default to a "nice" directory.

The Idle you get with this "corrupts" more easily, since the "-n" says
"no subprocess."  Things like restarting the shell don't work.  _But_
Tkinter stuff is available (there is already a running mainloop).  You
can interactively do simple things a step at a time and watch the
results.  It is a _great_ way to experiment with Tkinter.


--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-list mailing list