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

Gregor Lingl glingl at aon.at
Fri Sep 26 05:48:34 EDT 2003



Hi!

>
>
> Conlusion: There is a bug somewhere, but I can't even loacate it exactly.

I think (I hope) that I've found the bug in turtle.py. It has to do with 
updating the Canvas.
This is not done, when tracer(0) is issued.

Updating is regularely done in _draw_turtle. But not, if  self._tracing 
is turned off.
- see line 290 of turtle.py - .

So there we have to insert a statement for updating the canvas. E.g.:

    def _draw_turtle(self,position=[]):
        if not self._tracing:
            self._canvas.update()   #  <== Insert this line
            return
        if position == []:
            #  etc. etc.


With this correction interactive use of turtle.py is possible and demo 
runs as expected.
Without it the program seems to remain hanging because of some pending 
(update?)
events?

The turtle-window has still to be closed via Shell/restart as Kirby 
suggested.

(I  must confess that I still not have a profound understanding of the 
problem, and
maybe there are similar pitfalls in the code of turtle.py still hanging 
around).

I'll test this extensively soon.

Regards, Gregor

>
>
> Examples 2, concerning a different sort of problem:
>
> RestartIDLE
>
> >>> from Tkinter import *
> >>> root = Tk()    # Nothing happens; in IDLE 0.8 a tiny empty 
> Tk-Window appeared
> >>> cv = Canvas(root)
> >>> cv.pack()      # Still nothing happens; in IDLE 0.8 you saw the 
> Canvas packed intp
>                   # the TK window (default-size of the Canvas)
> >>> root.mainloop()  # this was not advised in IDLE 0.8
>
> Now the Tk-Window appears on the screen (same appearance as in IDLE 0.8)
> but - of course - I cannot input any more statements into IDLE, I think
> because of the running mainloop(). Only when I close the newly created 
> window
> IDLE is ready for more input.
>
> Conclusion: I can't play around any more with Tkinter windows 
> interactively.
>
> Any ideas?
>
> Gregor
>
>
> Kirby Urner schrieb:
>
>>> Hi Kirby,
>>> this definitely doesn't work on my machine (Windows XP with Python 3.2)
>>>   
>>
>>
>> I just downloaded 2.3.1 today or yesterday.  That couldn't be the 
>> difference
>> could it?  Windows XP here too.
>>
>> 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. 
>> For example, if I hit the maximize icon, nothing happens.  But next 
>> time I
>> go up(), the window maximizes (i.e. the action occurs only on 
>> programmatic
>> refresh).  Likewise to shrink it down again (using the icon) -- the 
>> resize
>> event is postponed until the next turtle event.
>>
>> If the secondary window minimizes to the task bar, I double-click on it.
>> Then I go up() or setx() or something, and it tends to return to its
>> previous (open) state.
>>
>> If a window moves in front of the secondary window, and then is moved 
>> away,
>> the secondary window will not refresh and is likely blank -- until 
>> the next
>> turtle event.
>>
>> Kirby
>>
>>
>>
>>
>>  
>>
>
>
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>
>




More information about the Edu-sig mailing list