[Edu-sig] Tkinter window behind IDLE under Mac OS X

Peter Drake drake at lclark.edu
Wed Jan 31 01:10:07 CET 2007


I tried running this directly from a terminal:

#!/usr/local/bin/python
from Tkinter import *
c = Canvas()
c.pack()
c.create_line(0, 0, 20, 30)
mainloop()

Again, the Tk window pops up behind the terminal.

What next? Is there some command to bring the window to the front?

Peter Drake
Assistant Professor of Computer Science
Lewis & Clark College
http://www.lclark.edu/~drake/




On Jan 30, 2007, at 3:26 PM, kirby urner wrote:

>
> Hi Peter --
>
> In general, developing with Tkinter from inside of IDLE doesn't  
> work well,
> because IDLE itself is working a Tk mainloop and the two don't play  
> well
> together (they both want to be "main").
>
> You can still use IDLE as your text editor if you invoke your  
> Tkinter-using
> code in another process, perhaps directly from a terminal window, e.g.
> simply by entering the name of the .py module -- assuming appropriate
> #! and/or other file association infrastructure.
>
> Kirby
>
>
> On 1/30/07, Peter Drake <drake at lclark.edu> wrote: Forgive me if  
> this isn't the appropriate place to post...
>
> I'm trying to write a very simple set of graphics functions for use
> by my (non-CS-major) students. Playing with Tkinter, I wrote this:
>
> from Tkinter import *
>
> c = Canvas()
> c.pack()
> c.create_line(0, 0, 20, 30)
> mainloop()
>
> It does, as hoped, produce a window with a little diagonal line in
> it. The problem is that this window pops up BEHIND the IDLE window.
> Googling around, I've found several other people who have had this
> problem (especially under Mac OS X), but no solutions. Is there a
> workaround?
>
> I'd just as soon get rid of the "Console" window, too, but that's
> less important.
>
> Thanks in advance for any help you can offer,
>
> Peter Drake
> Assistant Professor of Computer Science
> Lewis & Clark College
> http://www.lclark.edu/~drake/
>
>
>
> _______________________________________________
> 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