Using IDLE or PythonWin and TkInter

Reuben Sumner rasumner at iname.com
Tue Feb 29 11:36:31 EST 2000


(I appologize that this isn't referenced properly to the original message.
It isn't on my news server anymore.

In article <1260876475-6142791 at hypernet.com>,
  gmcm at hypernet.com wrote:
> Anders M Eriksson writes:
> >
> > I have copied example 2 from Fredrik Lundh's "An Introduction to
> > Tkinter". when I run it this happens:
> >
> > Using PythonWin: PythonWin hangs or crashes!
> >
> > Using IDLE: The hello2 app runs but when I click on the QUIT button is
> > also closes IDLE..
> Every GUI has an app message queue and a mainloop. Trying
> to have more than one of each in one process is similar to
> letting one 3 year old work the steering wheel while his friend
> works the pedals.

I recently got around this problem as follows

Easy solution: If the Tkinter app doesn't need any special code run when the
window is closed do nothing and DO NOT call mainloop() from your Tkinter app
(while in IDLE, outside of IDLE you will need to add the call again).

Solution B:

Write a close() method and have it be called by any cancel buttons as well
as doing a master.protocol("WM_DELETE_MESSAGE",self.closeit).

Then
def closeit(self):
    self.master.quit() #exit out of this mainloop()
    self.master.destroy() # actually close the window

In the first solution IDLE will actually be fully functional while your app
is running.  In the second case idle will not be fully interactive until you
close your app down.

Reuben






More information about the Python-list mailing list