[Idle-dev] Interruptable code?

Douglas S. Blank dblank at brynmawr.edu
Sat Dec 16 15:31:22 CET 2006


On Sat, December 16, 2006 3:21 am, Kurt B. Kaiser said:

[snip]

> def func():
>     while True:
>           if flist.pyshell.canceled:
>                 break
>
> while True: func()
>
> (works w/o subprocess)

Thanks! That will do it.

>> - I can't use idle with sub processes (because I want to interact with
>> Tkinter in a single thread)
>
> If you run with the subprocess and construct Tkinter objects, they run in
> a process separate from the IDLE GUI.  This is an advantage in most cases!

Yes, I realize that. But there is one important case where it is not:
interactively creating and using Tkinter and/or the Python prompt. For
example, being able to create a window and interactively type in commands
to alter the window. Maybe I am using Tkinter incorrectly from Idle? When
I type:

>>> import Tkinter
>>> tk = Tkinter.Tk()

in idle -n (or raw Python), I get to interactively manuipulate Tk windows.
When run in idle with subprocesses, it doesn't show any windows until a
mainloop() (or similar method) is called.

This "problem" has caused John Zelle to have to add code to his
graphics.py so that Tkinter will work the same in both methods of running
Idle. See:

http://mcsp.wartburg.edu/zelle/python/index.html

and look at graphics.py.

Is there an option I'm not aware of? (BTW, I do what a solution to work on
Windows, Mac, and Linux).

Thanks again!

-Doug

> One of the objectives for implementing the subprocess was to separate
> the IDLE GUI from the user code.  The user code can be interrupted even
> in
>
> while True: pass
>
> (But IDLE Windows has problems with killing user code which is blocked.)
>
> --
> KBK
>


-- 
Douglas S. Blank
Associate Professor, Bryn Mawr College
http://cs.brynmawr.edu/~dblank/
Office: 610 526 601



More information about the IDLE-dev mailing list