954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

wxPython, biding events to a wx.GenericDirCtrl

Hi everyone :)

Title says it all... I'm trying to bind events to a wx.GenericDirCtrl.

I've visited more than 20 web sites but i haven't found how to do it. I've tried different manners but it doesn't work as i expect it to.
In some case my control is seen as a normal TreeCtrl and i can't use with it the GetFilePath method of the GenericDirCtrl (
docs/api/wx.GenericDirCtrl-class
), in other case i can't get all the path of the selected file and folder in the tree, GetFilePath gives just the name...

Help me please to make it do its job!

Here is my code:

#The tree
filesNav = wx.GenericDirCtrl(self.nBpane2, 210, dir=hp, pos=wx.DefaultPosition, size=wx.DefaultSize, filter="Fichier PHP (*.php)|*.php", style=0)

#Biding event
filesNav.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSel)


### A method
def OnSel(self, event):
    item = event.GetFilePath()
    print item


### Error:
#
# Traceback (most recent call last):
# File "./Main.py", line 419, in OnSel
#   item = event.GetFilePath()
# AttributeError: 'TreeEvent' object has no attribute 'GetFilePath'


Thanks a lot!

stefh
Light Poster
47 posts since Feb 2011
Reputation Points: 10
Solved Threads: 3
 

Isn't it self not event? How could event have such method?

pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

Thanks a lot pyTony! Solved...

def OnSel(self, event):
    item = filesNav.GetFilePath()
    print item
stefh
Light Poster
47 posts since Feb 2011
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: