GUI Program Error

Scott David Daniels scott.daniels at acm.org
Thu Jun 8 12:29:08 EDT 2006


John Salerno wrote:
 > <Next from Fredrik Lundh>
 >> <Quoting Eric Brunel>
>>> It may be a platform-specific issue: On Unix/Linux, a window *does* 
>>> appear  when you instantiate Tk, at least with tcl/tk 8.3 and 8.4 
>>> (which is the  latest stable version AFAIK).

Here you should have chimed in with your OS and Python versions.

>> same on Windows, but it often appears *beneath* the window you're 
>> typing into, so you have to look for it in the task bar.
>>
>> this also relies on Python being able to keep the Tkinter event loop 
>> going behind the scenes; different command-line implementations have 
>> different limitations.
>>
>> for example, on Windows, the event loop runs only when you're at an 
>> empty Python prompt; as soon as you start typing the next command, the 
>> interpreter switches over to "text input mode", and the event loop is 
>> paused until you press return.
> 
> I thought it might be something like that. A window doesn't appear for 
> me at all, but it may be because I haven't updated Tkinter since 
> installing Python, so maybe it's a little older.

When running on Windows 2000 (at least), with Python 2.3 or greater,
Idle now (by default) stays more separate from the process running the
user's code.  As a result, debugging and namespaces are more stable, but
the users space doesn't have a display loop running.  To help out in
cases like this, Idle has the "-n" switch which means roughly "no
subprocess."  If you are on windows (I have no idea what system you are
running on), you can create a shortcut like I have (I call it Py24One).
I just copied the Idle shortcut, and changed the "target"
from:
         C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.pyw
to:
         C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.pyw -n

That "target", by the way, can also be typed directly to the command
line to start Idle in "no subprocess" mode.

The big advantage to using Idle this way is that (because Idle is
already running a display loop), you can see the effects of your
commands immediately.  So the comments in your intro will hold true.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list