
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.82 KB | hits: 12 | expires: Never
Python wxTree saving the tree to file
def project_save(self):
try:
output = open(self.project_file, 'w+')
output.write(self.tree.GetItemText(self.root) + 'n')
count = self.tree.GetChildrenCount(self.root)
iter = 0
child = ''
for i in range(count):
if i == 0:
child, cookie = self.tree.GetFirstChild(self.root)
else:
child, cookie = self.tree.GetNextChild(self.root, cookie)
output.write(self.tree.GetItemText(child) + 'n')
output.close()
self.projectdirty = False
except IOError:
MsgDlg(self, 'There was an error saving the new project file.', 'Error!', wx.OK)
root
|
---item
|
---item
root
|
---item
|
---item
|
-node
|
---item
|
---item