[Dev] Re: Don't forget to Call Destroy on your dialogs

Kevin Altis altis at semi-retired.com
Mon Jul 14 14:35:30 PDT 2003


> From: Kaitlin Duck Sherwood
>
> Robin Dunn wrote:
>
> > Anytime you create an *instance of a wxDialog class* you need to call
> > its Destroy method when you are done.  If you use one of the *helper
> > functions* like wxMessageBox or wxFileSelector then you don't need to
> > call it since the dialog is destroyed inside the funciton, (and you
> > can't call it anyway since you don't have an instance.)
>
>
> FYI: Here is a list of Dialog functions:
>    http://www.freiburg.linux.de/~wxxt/wxHTML/wxwin396.htm
>
> (For those of you on the dev list, who feel like you're coming in late,
> you are.  This was accidentally posted to the internal list and
> discussed for a few rounds before we realized that it should be on
> dev.   What you missed was John reminding people to destroy their
> Dialogs, a question about how to destroy wxMessageBoxes, then Robin's
> pronouncement that wxMessageBoxes didn't need to be destroyed.)

The helper functions are in wxPython.lib.dialogs. The function calls work
very nicely since they wrap modal dialogs and the module contains a test for
all wrapped dialogs, so you can try them out. The returned result is a
class, but there is a __repr__ method to simplify result display in the
shell. Here's a simple example:

>>> from wxPython.lib import dialogs
>>> result = dialogs.messageDialog(None, 'hello message', 'title')
>>> result.accepted
1
>>> result
{'returnedString': 'Ok', 'accepted': 1, 'returned': 5100}

AFAIK, there is no lost functionality by using the wrapper functions. The
print related dialogs were never wrapped, so if you want those and/or want
another refactor of the existing wrappers just say so. It is easy enough to
roll your own for Chandler, but it would be nice to have a wxPython
standard.

ka
---
Kevin Altis
altis at semi-retired.com
http://altis.pycs.net/
http://www.pythoncard.org/




More information about the Dev mailing list