CustomTreeCtrl Edit Labels Bug?

Hi Kyle,

···

On Jan 30, 2008 9:20 PM, Rickey, Kyle W wrote:

Using wxpython 2.8.7.1 on window xp and python 2.5

When editing labels in the custromtreectrl, if text is selected when you
press enter, whatever was selected is deleted. Is this a bug? This does
not happen when I press escape or click on another tree item.

import wx
import wx.lib.customtreectrl as CT

class MainWindow(wx.Frame):
        def __init__(self, parent, id, title):
                wx.Frame.__init__(self, parent, wx.ID_ANY, title)
                self.tree = CT.CustomTreeCtrl(self, -1,

style=wx.TR_DEFAULT_STYLE|wx.TR_HAS_BUTTONS|

wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_MULTIPLE|wx.TR_EDIT_LABELS|

wx.TR_HAS_VARIABLE_ROW_HEIGHT)

                root = self.tree.AddRoot("Root Item")
                for x in range(0, 7):
                        self.tree.AppendItem(root, "Some Long Item
"+str(x))
                self.tree.Expand(root)

                self.Center()
                self.Show()

app = wx.App(0)
frame = MainWindow(None, -1, "Test Edit Control")
app.MainLoop()

Yes, it's a bug :frowning: . I am updating the SVN right now, I'll work on it
and I will report back when it's fixed.

Thank you for the bug report!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Hi Kyle,

···

On Jan 30, 2008 9:29 PM, Rickey, Kyle W wrote:

Andrea, thanks for your quick response. I wasn't sure if it was a MSW
problem or not.

This should be fixed in SVN right now. Would you mind trying it and
report back if it works? Also reports on other platform behaviours is
more than welcome :-D.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

Hi, I try to import using statement:

import wx.lib.customtreectrl as CT

and I get:

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File
"C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\lib\customtreectrl.
py", line 310, in <module>
    from wx.lib.embeddedimage import PyEmbeddedImage
ImportError: No module named embeddedimage

Where do I get that module?

Kyle Rickey

···

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Wednesday, January 30, 2008 2:59 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] CustomTreeCtrl Edit Labels Bug?

Hi Kyle,

On Jan 30, 2008 9:29 PM, Rickey, Kyle W wrote:

Andrea, thanks for your quick response. I wasn't sure if it was a MSW
problem or not.

This should be fixed in SVN right now. Would you mind trying it and
report back if it works? Also reports on other platform behaviours is
more than welcome :-D.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Actually, I've just narrowed down the problem a bit more. Highlight an
item, press F2, press Ctrl-C, press Enter. Now, press F2 again, then
Ctrl-V, there is a \n character.

Now, try this: highlight an item, press F2, press End. Now hold Shift
and press Home, press Ctrl-C. Now when that is pasted, there is not \n
character. I wonder if this is specific to MSW?

-Kyle Rickey

···

-----Original Message-----
From: Rickey, Kyle W
Sent: Wednesday, February 06, 2008 3:35 PM
To: wxPython-users@lists.wxwidgets.org
Subject: RE: [wxPython-users] CustomTreeCtrl Edit Labels Bug?

Andrea, how about this one. When editing labels by pressing F2, I set
the selection of the editcontrol with

self.tree.GetEditControl().SetSelection(-1, -1)

Now, run the following, highlight a tree item, hit F2, then paste some
text. On MSW, this appends an extra \n character. Is this a problem with
my code or something else? I supposed I could add a check when
wx.EVT_TREE_END_LABEL_EDIT is sent and remove the extra \n. Any
thoughts?

import wx
import wx.lib.customtreectrl as CT

class MainWindow(wx.Frame):
  def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, wx.ID_ANY, title)
    self.tree = CT.CustomTreeCtrl(self, -1,
  
style=wx.TR_DEFAULT_STYLE|wx.TR_HAS_BUTTONS|
  
wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_MULTIPLE|wx.TR_EDIT_LABELS|
  
wx.TR_HAS_VARIABLE_ROW_HEIGHT)
    
    root = self.tree.AddRoot("Root Item")
    for x in range(0, 7):
      self.tree.AppendItem(root, "Some Long Item
"+str(x))
    self.tree.Expand(root)
    
    self.tree.Bind(wx.EVT_TREE_KEY_DOWN, self.OnKeyDown)
      
    self.Center()
    self.Show()

  def OnKeyDown(self, event):
    key = event.GetKeyEvent().GetKeyCode()
    if key == wx.WXK_F2:
      item = self.tree.GetSelection()
      self.tree.EditLabel(item)
      self.tree.GetEditControl().SetSelection(-1, -1)
    else:
      event.Skip()

app = wx.App(0)
frame = MainWindow(None, -1, "Test Edit Control")
app.MainLoop()

-Kyle Rickey

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Wednesday, January 30, 2008 2:26 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] CustomTreeCtrl Edit Labels Bug?

Hi Kyle,

On Jan 30, 2008 9:20 PM, Rickey, Kyle W wrote:

Using wxpython 2.8.7.1 on window xp and python 2.5

When editing labels in the custromtreectrl, if text is selected when

you

press enter, whatever was selected is deleted. Is this a bug? This

does

not happen when I press escape or click on another tree item.

import wx
import wx.lib.customtreectrl as CT

class MainWindow(wx.Frame):
        def __init__(self, parent, id, title):
                wx.Frame.__init__(self, parent, wx.ID_ANY, title)
                self.tree = CT.CustomTreeCtrl(self, -1,

style=wx.TR_DEFAULT_STYLE|wx.TR_HAS_BUTTONS|

wx.TR_FULL_ROW_HIGHLIGHT|wx.TR_MULTIPLE|wx.TR_EDIT_LABELS|

wx.TR_HAS_VARIABLE_ROW_HEIGHT)

                root = self.tree.AddRoot("Root Item")
                for x in range(0, 7):
                        self.tree.AppendItem(root, "Some Long Item
"+str(x))
                self.tree.Expand(root)

                self.Center()
                self.Show()

app = wx.App(0)
frame = MainWindow(None, -1, "Test Edit Control")
app.MainLoop()

Yes, it's a bug :frowning: . I am updating the SVN right now, I'll work on it
and I will report back when it's fixed.

Thank you for the bug report!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Kyle,

Actually, I've just narrowed down the problem a bit more. Highlight an
item, press F2, press Ctrl-C, press Enter. Now, press F2 again, then
Ctrl-V, there is a \n character.

Now, try this: highlight an item, press F2, press End. Now hold Shift
and press Home, press Ctrl-C. Now when that is pasted, there is not \n
character. I wonder if this is specific to MSW?

I have no idea... I don't even know if there is a simple solution to
that, as it looks like MSW is appending a \n at the end of the item
text when you press Ctrl+C and then Ctrl+V. I don't know if it happens
on other platforms as well. If it does, someone more knowledgeable
than me might suggest a solution.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On Feb 6, 2008 10:42 PM, Rickey, Kyle W wrote:

Andrea, I guess in the meantime I can add a check when
EVT_END_LABEL_EDIT is sent, like:

text = self.tree.GetEditControl().GetValue()
while text.endswith("\n"):
  text = text[0:-1]

That prevents it from inserting the \n into my database, but the tree
item still has the \n character. Is there any way to add validation to
the tree edit control?

-Kyle Rickey

···

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, February 07, 2008 2:48 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] CustomTreeCtrl Edit Labels Bug?

Hi Kyle,

On Feb 6, 2008 10:42 PM, Rickey, Kyle W wrote:

Actually, I've just narrowed down the problem a bit more. Highlight an
item, press F2, press Ctrl-C, press Enter. Now, press F2 again, then
Ctrl-V, there is a \n character.

Now, try this: highlight an item, press F2, press End. Now hold Shift
and press Home, press Ctrl-C. Now when that is pasted, there is not \n
character. I wonder if this is specific to MSW?

I have no idea... I don't even know if there is a simple solution to
that, as it looks like MSW is appending a \n at the end of the item
text when you press Ctrl+C and then Ctrl+V. I don't know if it happens
on other platforms as well. If it does, someone more knowledgeable
than me might suggest a solution.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org