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!

Recommended Answers

All 2 Replies

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

Thanks a lot pyTony! Solved...

def OnSel(self, event):
    item = filesNav.GetFilePath()
    print item
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.