[Edu-sig] Interactive Tkinter graphics under IDLE

John Zelle john.zelle at wartburg.edu
Wed Feb 7 01:20:45 CET 2007

Hi Peter,

On Tuesday 06 February 2007 5:04 pm, Peter Drake wrote:
> Yes, and you're the third person to have suggested it today. (Nice
> book, by the way!)
> Three things prevent me from using your package as-is:
> 1) The graphics window appears BEHIND the Console window (which in
> turn appears behind the IDLE window).

You're right that on some platforms Tk windows will not "surface." I haven't 
found a way around this problem yet. I don't understand what you mean by the 
Console window. Aren't you using IDLE's shell?

In general the popping up behind problem is not a big deal since you can just 
click on the appropriate icon on the task bar to bring it to the front 
(Windows and Linux). Although this may not work on the Mac...

> 2) Once the main loop starts, you can't enter new commands into the
> IDLE shell.

I don't understand this comment. Are you running IDLE in it's normal mode 
(with a separate subprocess for user code)? I expended a fair amount of 
effort making my graphics library play nicely with IDLE. The mainloop is 
completely hidden in the graphics module, and you can continue interacting 
with any number of graphics objects and/or windows at the IDLE shell. If 
that's not working for you, make sure to get the newest version of the 
library. BTW if you are running IDLE in the no-subprocess (-n) mode, then you 
might want to use the older (non-threaded) version of the library.

> 3) It is object-oriented, confusing students with the combination of
> regularFunctions() and object.methods(). I'd just as soon avoid this
> if possible.

I can understand this if that's your goal. My point was to use graphics as a 
very concrete way to introduce the idea of objects.  I don't find that my 
students have any problems at all with using objects (writing their own 
classes is another story).

> If anyone can direct me to a way around the first two problems I
> could, of course, write wrapper functions to deal with the third.

Yes, it would be very easy to wrap flat functions around my graphics library 
if you restrict yourself to one graphics window. 


> Peter Drake
> Assistant Professor of Computer Science
> Lewis & Clark College
> http://www.lclark.edu/~drake/
> On Feb 6, 2007, at 2:23 PM, John Zelle wrote:
> > Hi Peter,
> >
> > Just a quick question for you. I am wondering if you have checked
> > out the
> > simple graphics package that I built on top of Tkinter for doing
> > these sorts
> > of simple manipulations. It's also name graphics.py. If you haven't
> > seen it,
> > you can check it out at: http://mcsp.wartburg.edu/zelle/python.
> > It's probably that case that it doesn't meet your needs, but if it
> > does it
> > would keep you from aving to "reinvent the wheel."
> >
> > --John
> >
> > On Tuesday 06 February 2007 1:03 pm, Peter Drake wrote:
> >> Okay, so I've got a simple system worked up that allows students
> >> (these are "CS0" non-CS-majors) to manipulate objects with commands
> >> in the IDLE command window. The file is attached.
> >>
> >> The next thing I'd like to do is define a function mouse() that
> >> starts the main loop, waits for a mouse click, stops the main loop,
> >> and returns the coordinates of the mouse click. Any suggestions?
> >
> > --
> > John M. Zelle, Ph.D.             Wartburg College
> > Professor of Computer Science    Waverly, IA
> > john.zelle at wartburg.edu          (319) 352-8360
> > _______________________________________________
> > Edu-sig mailing list
> > Edu-sig at python.org
> > http://mail.python.org/mailman/listinfo/edu-sig

John M. Zelle, Ph.D.             Wartburg College
Professor of Computer Science    Waverly, IA     
john.zelle at wartburg.edu          (319) 352-8360  

More information about the Edu-sig mailing list