| Store | Cart

[Edu-sig] How to explore Tkinter interactively with IDLE 1.0

From: John Zelle <john...@wartburg.edu>
Fri, 26 Sep 2003 17:13:12
Hello all,

I just wanted to confirm what has been reported here regarding IDLE 1.0. 
I have a simple 2D graphics package that I developed for CS1. It is 
basically a thin wrapper over a TK canvas. With versions of IDLE prior 
to 1.0, it was easy to experiment with the graphics interactively. Now, 
that is much harder. The basic problem is that the eventloop in the 
subprocess window is suspended when the IDLE interactive shell is 
waiting for input. As has already been reported, judicious calling of 
update() can be used to force the window to flush its queue. You can 
call update() from the IDLE shell to force the window to react.

For example:

 >>>  from Tkinter import *>>>  win = Tk()  # nothing appears>>>  win.update()  # Tk window pops up>>>  # now click in the close box of the Tk window, nothing happens>>> win.update() # Tk window closes

The interesting thing is that events are getting posted even when the 
window is unresponsive. As this example shows, the click in the close 
box is carried out when the update() call is made.

Under Windows, subprocess Tk windows are completely unresponsive and 
often pop up underneath the IDLE window.  If you drag the Tk window with 
the mouse, nothing seems to happen, but typing win.update() in the shell 
will cause the Tk window to jump to the new location. Under Linux, the 
situation is slightly better, the window is still under control of the 
window manager and can be moved and resized, but Tk events do not occur 
until an update().

My partial solution to this problem has been to add updates() to my 
library. But realistically, if you want to do interactive 
experiementation with Tkinter, the DOS or Linux command line is the 
better route now. It would be nice if this could be fixed, but I'm 
willing to give this up for the other features introduced by the IDLE fork.

--John

Gregor Lingl wrote:

>>> Dethe Elza schrieb:>>> On Thursday, September 25, 2003, at 10:09 PM, Kirby Urner wrote:>>>>> It's true for me as well that when I first say up(), the Tk window >>> is behind>>> the main one.  I see it by sliding the main one out of the way.  I >>> don't>>> touch the secondary one.>>>>>> The secondary window (showing the turtle) is not responsive in the >>> usual>>> way.>>>>>>>> This is the case for me when I try using turtle commands from the >> python interpreter interactively, so it doesn't seem to be limited to >> Idle behaviour.  I'm using Python 2.3 on OS X (10.2) with the native >> Tk library.  I cannot close the Tk window.  When I click in the >> window the interpreter prints>>>> >>> SetFrontProcess failed,-606>>> Hi Dethe,> this doesn't occur under Windows. With commandline-python works as > expected.>> Moreover the Tk - example from my prior posting works also with Python > 3.2.1> command line interpreter exactly as it did with IDLE 0.8 in earlier > Python versions.>> Regards, Gregor>>>>> And the window has none of the control buttons or drag bar enabled.  >> OS X has some issues normally with starting up GUI windows from the >> command-line, but you can generally interact with them.>>>> I hadn't played with the turtle package (I should look at it, since >> I've written my own incomplete turtle program with totally different >> interaction).  This was fun:>>>> def zap(x):>>   for i in range(0, x * 5, 5):>>     circle(i)>>>> for x in range(8):>>   right(60)>>   zap(x + 5)>>>> It needs sound effects, though.>>>> --Dethe>>>>>> _______________________________________________>> Edu-sig mailing list>> Edu-...@python.org>> http://mail.python.org/mailman/listinfo/edu-sig>>>>>>> _______________________________________________> Edu-sig mailing list> Edu-...@python.org> http://mail.python.org/mailman/listinfo/edu-sig>>

-- 
    John M. Zelle, Ph.D.   |     Wartburg College    
   Associate Prof. of CS   |  Dept. Math/CS/Physics  
  john...@wartburg.edu  |     Waverly, Iowa       

Recent Messages in this Thread
Gregor Lingl Sep 26, 2003 12:59 pm
John Zelle Sep 26, 2003 05:13 pm
Guido van Rossum Sep 26, 2003 05:34 pm
Gregor Lingl Sep 26, 2003 06:32 pm
Guido van Rossum Sep 26, 2003 06:40 pm
Guido van Rossum Sep 26, 2003 05:54 pm
Dethe Elza Sep 26, 2003 12:34 pm
Messages in this thread