ANN: CustomTreeCtrl For wxPython ;-)

Andrea,

I guessed that the "IsOk" was no longer needed, but to make this a drop-in replacement, I've added a no-op method:

     def IsOk(self):
         """ Returns Whether The Item Is Ok Or Not. """

         return True

In methods such as this InsertItem, you used "type" as a keyword (here I've changed it to "ct_type"). It breaks when you use the built-in function "type" in

         if type(input) == type(1):

Changing this will break the demo.

     def InsertItem(self, parentId, input, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
         """ Inserts An Item After The Given Previous. """

         if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
             raise "\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT"

         if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
             raise "\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT"

         if type(input) == type(1):
             item = self.InsertItemByIndex(parentId, input, text, ct_type, wnd, image, selImage, data)
         else:
             item = self.InsertItemByItem(parentId, input, text, ct_type, wnd, image, selImage, data)

         return item

Also, InsertItem needs to return the item for other methods to use.

···

______________
John Jackson

Hello John,

thanks for the update. I have modified the “type” thing to ct_type, as you suggested. However, I was unable to break the demo as you did… mine did not raise that error. Probably is because I have already redefined all the constants like TR_* to their wx values… I donàt know. I am thinking about adding IsOK() to always return True (in the first CustomTreeCtrl, this was the first implementation I have done, but then I got upset in seeing a method that always returns True…). Well, it doesn’t hurt anyway.

I have modified insertitem to return the item… evidently I was thinking about something else when I implemented that function :slight_smile:

Have you done something special to break the demo?

Andrea.