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 (
), 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

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

Jump to Post

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 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.