Hi folks,
I have a strange problem that I don't understand and I
am trying to resolve. My program runs fine until I
open up the following dialog with a ShowModal() call.
After I call the dialog, the python interpreter will
not close when my main program terminates. Here's how
I'm calling the dialog. Note: I had to insert the
sys.exit() to get the program to quit. I'm taking
data from a wxFrame.wxTreeCtrl to the
wxDialog.wxTreeCtrl (modifying it slightly). If the
user approves, I then save the data. What could I
possibly be doing which would cause the python
interpreter to not close when I do a self.Destroy()
···
=====================================================================================
viewDialog = wxDialog1.create(None)
dstRoot = viewDialog.treeCtrl1.AddRoot("Sorted
Microsoft Tasks")
srcRoot = self.treeCtrl1.GetRootItem()
cookie = 0
data = []
[priority, cookie] =
self.treeCtrl1.GetFirstChild(srcRoot,cookie)
for iOuter in
range(self.treeCtrl1.GetChildrenCount(srcRoot,FALSE)):
id = chr(ord('A')+iOuter)
taskcookie = 1
[task, taskcookie] =
self.treeCtrl1.GetFirstChild(priority,taskcookie)
for iInner in
range(self.treeCtrl1.GetChildrenCount(priority,FALSE)):
taskData =
self.treeCtrl1.GetPyData(task)
newSubject = "%s%d: %s" % (id,
iInner+1, taskData[0])
data.append( [taskData[1], newSubject]
)
viewDialog.treeCtrl1.AppendItem(dstRoot,newSubject +
taskData[1].Body)
[task, taskcookie] =
self.treeCtrl1.GetNextChild(priority,taskcookie)
[priority, cookie] =
self.treeCtrl1.GetNextChild(srcRoot,cookie)
viewDialog.treeCtrl1.Expand(dstRoot)
if viewDialog.ShowModal():
for task in data:
if task[0].Subject != task[1]:
task[0].Subject = unicode(task[1])
task[0].Save()
wxMessageBox("Tasks Saved", "Complete",
wxOK)
sys.exit(0)
The actual frame is declared as follows:
#Boa:Dialog:wxDialog1
from wxPython.wx import *
def create(parent):
return wxDialog1(parent)
[wxID_WXDIALOG1, wxID_WXDIALOG1RETURNBUTTON,
wxID_WXDIALOG1SAVEBUTTON, wxID_WXDIALOG1TREECTRL1] =
map(lambda _init_ctrls: wxNewId(), range(4))
class wxDialog1(wxDialog):
def _init_utils(self):
# generated method, don't edit
pass
def _init_ctrls(self, prnt):
# generated method, don't edit
wxDialog.__init__(self, id = wxID_WXDIALOG1,
name = '', parent = prnt, pos = wxPoint(312, 101),
size = wxSize(1050, 720), style =
wxDEFAULT_DIALOG_STYLE, title = 'wxDialog1')
self._init_utils()
self.SetClientSize(wxSize(1042, 693))
EVT_SIZE(self, self.OnWxdialog1Size)
self.saveButton = wxButton(id =
wxID_WXDIALOG1SAVEBUTTON, label = 'Save Tasks', name =
'saveButton', parent = self, pos = wxPoint(0, 0), size
= wxSize(96, 32), style = 0)
EVT_BUTTON(self.saveButton,
wxID_WXDIALOG1SAVEBUTTON, self.OnSavebuttonButton)
self.returnButton = wxButton(id =
wxID_WXDIALOG1RETURNBUTTON, label = 'Return to
Sorter', name = 'returnButton', parent = self, pos =
wxPoint(96, 0), size = wxSize(96, 32), style = 0)
EVT_BUTTON(self.returnButton,
wxID_WXDIALOG1RETURNBUTTON, self.OnReturnbuttonButton)
self.treeCtrl1 = wxTreeCtrl(id =
wxID_WXDIALOG1TREECTRL1, name = 'treeCtrl1', parent =
self, pos = wxPoint(0, 32), size = wxSize(616, 288),
style = wxTR_HAS_BUTTONS, validator =
wxDefaultValidator)
self.OnWxdialog1Size(None)
def __init__(self, parent):
self._init_ctrls(parent)
def OnWxdialog1Size(self, event):
w,h = self.GetClientSizeTuple()
self.treeCtrl1.SetDimensions(0, 32, w, h-32)
def OnSavebuttonButton(self, event):
self.SetReturnCode(1)
self.EndModal(1)
def OnReturnbuttonButton(self, event):
self.SetReturnCode(0)
self.EndModal(0)
TIA
Mike
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com