On Jul 20, 9:27 am, sturlamolden <sturlamol...@yahoo.no> wrote: > On 20 Jul, 16:17, Mel <mwil...@the-wire.com> wrote: > > > OTOH, if you intend to re-use the Dialog object, it's not a memory leak. > > It cannot be reused if you don't have any references pointing to it. > Sure it is nice to have dialogs that can be hidden and re-displayed, > but only those that can be accessed again.
I find that keeping a dialog alive (and hidden) is bad practice EXCEPT in the case where a dialog will be used many, many times in an application. Since that kind of re-usage is rare destroying the dialog and freeing the graphical resources it consumes is important. However a dialog should handle it's own state. That is, and application should never have to keep up with dialog default values and re-insert then every time, NO, the dialog should do this all by itself. My solution is to create a simple container class that creates and destroys the dialog as needed (when show is called) however keeps a state of the last user inputs so the main application does not have to. class Dialog(): def __init__(self): self.state = [] # the dialog IS NOT created here! def show(self): # Create the dialog here # and load any initial values # from self.state. def cb_okbutton(self): # Process the inputs, store the # current values in self.state # and destroy. def cb_cancelbutton(self) # destroy the dialog. This is a proper design pattern for all GUI dialogs. *school-bell* -- http://mail.python.org/mailman/listinfo/python-list