Not destroying wx.Dialog instances?

If I hadn't been bald already, I'd probably loose about a fistful of
my hair during last hour or so -- I have a moderately complex wxPython
application, and I (ab)use a lot of 'print's to profile my application
performance and sometimes do debug (now that I got WingIDE that's
gonna change :>).

Everything worked just fine up till now when I added rather simple
wx.Dialog to my application. There was nothing wrong with the app,
just my print&debug system stopped working. Nothing got printed to log
files (when running my app inside WingIDE debugger). When running
outside WingIDE just some random lines got printed, nothing useful.

So I wasted an hour trying to figure out what went wrong, and
apparently it was caused by not calling wx.Dialog.Destroy() on one of
dialogs. If someone could explain how it is possible that not
destroying the dialog could somehow interrupt wx.Apps redirect to log
file? And what puzzles me even more, how come even those 'print's that
came before creating that dialog did non get printed?

Ah, and yes, what other interesting consequences could I suffer for
not destroying my dialogs? I'm just wondering, in case something
equally weird happens in the future will I have to go hunting some
dialogs :).

···

--
Karlo Lozovina -- Mosor
"Parce mihi domine quia Dalmata sum."

Karlo Lozovina wrote:

If I hadn't been bald already, I'd probably loose about a fistful of
my hair during last hour or so -- I have a moderately complex wxPython
application, and I (ab)use a lot of 'print's to profile my application
performance and sometimes do debug (now that I got WingIDE that's
gonna change :>).

Everything worked just fine up till now when I added rather simple
wx.Dialog to my application. There was nothing wrong with the app,
just my print&debug system stopped working. Nothing got printed to log
files (when running my app inside WingIDE debugger). When running
outside WingIDE just some random lines got printed, nothing useful.

So I wasted an hour trying to figure out what went wrong, and
apparently it was caused by not calling wx.Dialog.Destroy() on one of
dialogs. If someone could explain how it is possible that not
destroying the dialog could somehow interrupt wx.Apps redirect to log
file?

I have no idea. Can you make a small sample that shows the problem?

And what puzzles me even more, how come even those 'print's that
came before creating that dialog did non get printed?

Ah, and yes, what other interesting consequences could I suffer for
not destroying my dialogs? I'm just wondering, in case something
equally weird happens in the future will I have to go hunting some
dialogs :).

The app's MainLoop method will exit when there are no more top-level windows (or wx.TaskBarIcons) left in the app. So if you don't destroy your dialogs then the app won't exit normally. Also since most widget objects hold a Python reference to themselves the Python objects for them won't be deleted either even if you no longer have and references to it yourself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!