pickling problems with Pmw/Tkinter

Eric Brunel eric.brunel at pragmadev.com
Mon Jul 29 04:03:35 EDT 2002


Don Arnold wrote:

> I'm trying to develop a Tkinter app that pickles the values of a couple of
> Pmw counters. Then on its next run, it unpickles these values and loads
> them back into the counters. That's the plan, anyway. Here's what I have:
> 
[snip code]
>         self.bind('<Destroy>',self.shutdown)

First: why do you make your app class inherit from Frame? I've seen many 
people doing that and I can't understand why. There are many things you can 
do on an actual window (in Tkinter words a Toplevel) that you just can't do 
on frames: "regular" menubars, specific events for windows, and so on...

So I would make app inherit from Tk or Toplevel and do the following:

self.protocol('WM_DELETE_WINDOW', self.shutdown)

This may solve the problem. In fact, with the binding on <Destroy>, I 
suspect the contained widgets to be destroyed *before* the binding is 
called. So the Pmw counters in your _minwordlen and _maxwordlen attributes 
may already have been destroyed. However, why no exception is raised is a 
mystery...

If you do it that way, put also a self.quit() in your shutdown method or 
the window won't close.

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list