[wxPython] wxTreeCtrl::GetPyData problem

I just installed the new version and unfortunately I've encountered a
problem. It appears GetPyData on the wxTreeCtrl doesn't work. The following
code:

def OnRightClick(self, event):
        pt = event.GetPosition()
        flag = 0
        item = self.HitTest(pt)
        (xmlnode, name) = self.GetPyData(item)
        self.SelectItem(item)
    .....

Produces this error.

Traceback (innermost last):
  File "C:\CVS\OPENRPG\xmlrpg.py", line 552, in OnRightClick
    (xmlnode, name) = self.GetPyData(item)
  File "C:\Program Files\Python\wxPython\controls2.py", line 636, in
GetPyData
    val = apply(controls2c.wxTreeCtrl_GetPyData,(self,) + _args, _kwargs)
TypeError: Type error in argument 2 of wxTreeCtrl_GetPyData. Expected
_wxTreeItemId_p.

It seems that nothing I give GetPyData is a valid tree item. Even if I do
something like this.

root = tree.AddRoot("Game Tree")
tree.SetPyData(self.nodes["root"],(None,"root"))
tree.GetPyData(root)

Anyone else encounter this problem? I'm using win98, btw. Havn't checked
the gtk version yet.

On a positive note, people might remember my whining the last few days over
my tree icons truning gray. Well, the new version has seem to fix that. :slight_smile:

chris davis
chris@rpgarchive.com

I just installed the new version and unfortunately I've encountered a
problem. It appears GetPyData on the wxTreeCtrl doesn't work. The

following

code:

def OnRightClick(self, event):
        pt = event.GetPosition()
        flag = 0
        item = self.HitTest(pt)
        (xmlnode, name) = self.GetPyData(item)
        self.SelectItem(item)
  .....

Hit test returns a tuple of two values. The tree item and a flags value.
If you change it to "item = self.HitTest(pt)[0]" it will probably work.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com

wxPython has moved Check it out!

Is HitTest() different from v2.1.13? Your suggestion work, but that code
worked prior to v2.1.15. Another version question, in v2.1.13 I could add
multiple roots to tree on windows. I noticed that doesn't work with
v2.1.15? is that by design? Just curious. Thanks again for the help.

···

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Robin Dunn
Sent: Wednesday, April 26, 2000 2:47 PM
To: wxpython-users@wxwindows.org
Subject: Re: [wxPython] wxTreeCtrl::GetPyData problem

I just installed the new version and unfortunately I've encountered a
problem. It appears GetPyData on the wxTreeCtrl doesn't work. The

following

code:

def OnRightClick(self, event):
        pt = event.GetPosition()
        flag = 0
        item = self.HitTest(pt)
        (xmlnode, name) = self.GetPyData(item)
        self.SelectItem(item)
  .....

Hit test returns a tuple of two values. The tree item and a flags value.
If you change it to "item = self.HitTest(pt)[0]" it will probably work.

--
Robin Dunn
Software Craftsman
robin@AllDunn.com

wxPython has moved Check it out!

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

Is HitTest() different from v2.1.13?

Yes. I think it was ignoring the flags previously and somebody asked about
how to get it.

Your suggestion work, but that code
worked prior to v2.1.15. Another version question, in v2.1.13 I could add
multiple roots to tree on windows. I noticed that doesn't work with
v2.1.15? is that by design? Just curious. Thanks again for the help.

Yes. It was disabled on Windows to be the same as on GTK. It wasn't real
bullet-proof on windows anyway, it could crashin certain situations.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com

wxPython has moved Check it out!