pickling problems with Pmw/Tkinter
Don Arnold
darnold02 at sprynet.com
Mon Jul 29 19:28:48 EDT 2002
On 29-Jul-2002, Eric Brunel <eric.brunel at pragmadev.com> 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...
I was inheriting from Frame because that's what "The Tkinter Life Preserver"
and Grayson's book use. I'll try inheriting from Toplevel and see how that
works.
>
> So I would make app inherit from Tk or Toplevel and do the following:
>
> self.protocol('WM_DELETE_WINDOW', self.shutdown)
I haven't seen this method used before, but I'm (obviously) pretty new to
Tkinter.
>
> 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.
>
I was thinking it had something to do with binding <Destroy>, since I later
added a 'Save' button to call the method explicitly and it worked fine.
> HTH
> --
> - Eric Brunel <eric.brunel at pragmadev.com> -
> PragmaDev : Real Time Software Development Tools -
> http://www.pragmadev.com
Thanks for all your help!
Don
More information about the Python-list
mailing list