Hello wxPython-users,
def doSomeDlg():
dlg = wx.Dialog(...)
return dlg.ShowModal()
is this correct?No. You still need to destroy it:
def doSomeDlg():
dlg = wx.Dialog()
result = dlg.ShowModal()
dlg.Destroy()
return result
but if python object dlg is automaticly destroyed,
why it cannot destroy its underlying wxPython object if it
not yet destroyed.
In my database project I use method validator.TransferFromWindow when
dealing with results of dialog window, thus I dont need to read dlg values
upon successful exiting from dialog. But as in c/c++ I may forget
explicitly destroy dialog. And to find why application does not
exit after closing last visible window is very hard. After all dlg
object is destroyed automatically. Why cant we use this lucky chance.
Those questions are arisen because I get some problem in this code:
variant 1:
class Catalog(wx.Frame):
def __init__(self, parent):
...
wx.EVT_LIST_COL_CLICK(self, listId, self.OnColLabelClick)
def OnColLabelClick(self, evt):
col = evt.GetColumn()
if col == 3:
dlg = priceEditDlg(self, ...)
dlg.ShowModal()
dlg.Destroy()
when clicking on column label of report wx.ListCtrl I show some
dialog. But just after creating and displaying this dialog very first
click on system button "Close" (small cross in the upper right
corner of the window) does nothing absolutely. But dlg window
is looking active. Only second click on that button does close
dialog! Whats the matter?
variant 2:
class Catalog(wx.Frame):
def __init__(self, parent):
...
wx.EVT_LIST_COL_CLICK(self, listId, self.OnColLabelClick)
def OnColLabelClick(self, evt):
col = evt.GetColumn()
if col == 3:
dlg = priceEditDlg(self, ...)
wx.CallAfter(dlg.ShowModal)
this works as expected - dialog disappears after first click on
system close button. But undestroyed dialog window gets somehow
been destroyed somewhere because application is exiting correctly.
I cannot explain this tricky behaviour.
I am using wxPython 2.4.1.2, Python 2.2.3, Windows 98
···
--
bye,
kvp