[Edu-sig] Re: Teaching graphics with Python (was Introductoryhighschool programming)

John Zelle john.zelle at wartburg.edu
Mon May 10 11:30:46 EDT 2004


A number of folks expressed interest, so the newest version of 
graphics.py is now available on my Python page:
http://mcsp.wartburg.edu/zelle/python/graphics.py

The only difference between this version and the previous is that it 
allows the auto-flush of graphics updates to be turned off. This line 
creates a graphics window w/o immediate automatic updates:

myWin = GraphWin("Example Graphics Window", 300, 300, False)

The "False" in the last parameter turns off auto-updates. This window 
will be updated when the Tk event loop is idle or when myWin.flush() is 
called.  I tested this out with Kirby's nks.py code, and it makes the 
drawing essentially instantaneous on my machine.

I normally do not release tweaks to the graphics package until it has 
gone through an entire semester of class-use testing, but I am 
relatively confident that this small change is working. The 
documentation has not yet been updated. Please let me know if you find 
any bugs.

By the way, for any who are interested in the history of such things, 
versions of my graphics package before 2.0 (the previous release) always 
used lazy updating (the auto-flush False behavior). I added the forced 
updates to version 2.0 to make the package behave better interactively 
under windows with Idle 1.0 and newer (using subprocesses). The newest 
version (2.1) now lets you select which mode you want.

--John

Gregor Lingl wrote:

>
>
> John Zelle schrieb:
>
>> ...
>> My latest version of the package (still in testing) adds an option to 
>> turn off the auto-flush. Using this option, you can do a bunch of 
>> draws before actually updating the view. 
>
>
> Interestigly the module turtle.py (in the standard distribution of 
> Python) already has a similar feature,
> namely the function (method) tracer().
>
>> I think the result would be a much faster draw, but it's still going 
>> to be slower than PIL
>>
>> If you're interested, I could post the latest version of graphics.py.
>>
> Yes, I'm also interested in this latest version.
>
>> This is problem with graphics.py. Tk provides a method to dump 
>> canvases to postscript, but the last time I checked it only worked 
>> under Unix/Linux. I'm not sure if this has been brought into the 
>> Windows world as well, I haven't looked recently.
>
>
> In my experience this still dowsn't work correctly.  A ps-file will be 
> produced but it displays
> only as a tiny blank rectangle.
>
> Regards, Gregor
>
>>
>> --John
>>
>
> _______________________________________________
> 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