[wxpython-users] problems with customtreectrl ...

Stef Mientki s.mientki at ru.nl
Wed Apr 2 13:46:33 PDT 2008


hello  (Andrea),

Although CT has some very nice features,
I think it still a bit buggy (or I don't use it correct ;-)
(I might have mentioned a few of these items in this list)
Solutions I found are created by trial and error, because this code is 
far beyond my knowledge)

* editor is multiline editor, which is quit ugly in single line applications
(remove wx.TE_MULTILINE in TreeTextCtrl at line 950)

* dragging is ugly when full line width highlight is on
(no solution)

* making the treewindow wider, when full line width highlight is o, 
gives weird rendering
( no solution)

* when focus is lost in edit mode, editor doesn't disappear.
This is a very serious bug, because also moving to another item in the 
tree while editing,
can give very weird effects (and even hang the program)
solution:
    def OnKillFocus(self, event):
        self._aboutToFinish = True
        self.AcceptChanges()
        wx.CallAfter(self.Finish)
        event.Skip()

Now this gives an error, so we also change
    def Finish(self):
      try:
        if not self._finished:
            self._finished = True
            self._owner.SetFocusIgnoringChildren()
            self._owner.ResetTextControl()
      except:
        pass

* Del-Key bound as an accelerator key prevents the use of del-key in editor.
solution, catch the onkeydown with a normal Bind :

    self.Bind ( wx.EVT_KEY_DOWN, self.OnMyKeyDown)
  def OnMyKeyDown ( self, event ) :
    if not ( self.GetEditControl () ) :
      if event.GetKeyCode() == wx.WXK_DELETE :
        self.Delete_Item ( self.GetSelection () )
      else :
        event.Skip()
    else :
      event.Skip()

* InsertItemBefore is not implemented,
solution, can be done through PrependItem

cheers,
Stef



More information about the wxpython-users mailing list