More Questions On wx.TreeCtrl

Rich Shepard rshepard at appl-ecosys.com
Wed Nov 1 08:16:08 PST 2006


   I don't see how to handle two situations despite reading Chapter 15 on
Tree Controls in xPIA, checking the demo code, and looking on the API page.

   This TreeCtrl allows users to enter items and sub-items (all under the
same root). However, if a user tries to enter a sub-item when there is no
parent item, an error message should appear rather than the text entry
dialog box. I don't have the syntax correct to do this. The following does
not work:

   def OnSubPolAdd(self, event):
     newSubPol = wx.TextEntryDialog(self, 'Add Sub-Policy name:',
                                 'Sub-Policy Name', style=wx.OK|wx.CANCEL|wx.CENTER)
     txt = None
     parent = None
     if (newSubPol.GetItem() == None):
       result = wx.MessageDialog(self, parent, 'No policy for a sub-policy.', 'Sub-Policy Add Failed',wx.OK | wx.ICON_ERROR)
       result.ShowModal()
       result.Destroy()
     if (newSubPol.ShowModal() == wx.ID_OK):
       txt = newSubPol.GetValue()
       subPolID = self.polTree.AppendItem(self.polID, 'txt')
       newSubPol.Destroy()

Python's error message is, "AttributeError: 'TextEntryDialog' object has no
attribute 'GetItem'" and I get a seg fault.

   The second issue is how to gracefully handle the user clicking on the
CANCEL key so that the dialog box is destroyed and I don't get a seg fault
as a result of the actiion.

   Either direct help or a pointer to an example would be appreciated.

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863




More information about the wxpython-users mailing list