Hi Frank,
Frank Millman wrote:
Hi all
Attached is a simple program. There is a frame with a button. Clicking the
button launches a dialog. I want to add various steps while setting up the
dialog, so I have the following -def onClick(self, evt):
self.dlg = MyDialog(self)
wx.CallAfter(self.showDlg)
wx.CallAfter(self.startDlg)def showDlg(self):
self.dlg.ShowModal()
self.dlg.Destroy()def startDlg(self):
self.dlg.t1.SetFocus()This works with MSW, and it worked with GTK2 using wxPython 2.6 (I skipped
2.7).With 2.8, startDlg() is only called after the dialog is destroyed, which is
obviously too late for my purposes.
I am surprised that this worked in 2.6 as you are calling startDlg after showDlg and it contains Destroy.
I always use try/finally with dialogs, to ensure that they get destroyed whatever happens with the dialog
def onClick(self, evt):
try:
self.dlg = MyDialog(self)
self.startDlg()
finally:
self.dlg.Destroy()
def startDlg(self):
self.dlg.t1.SetFocus()
self.dlg.ShowModal()
Maybe you would also want to do the setfocus in the dialog init or in a function in the dialog which you then call, e.g.:
def onClick(self, evt):
try:
self.dlg = MyDialog(self)
self.dlg.startDlg()
self.dlg.ShowModal()
finally:
self.dlg.Destroy()
Werner