I’m starting to learn wxPython to create GUI apps, and I am facing some problem: When using wx.DirDialog to pick some folder, no matter what the folder I chose, dlg.GetPath() always return the same folder, which is in my case: /home/loai
my binding function is as follows, it is straight forward :
def onButton(self,e):
dlg = wx.DirDialog(self, "Choose a directory:")
if dlg.ShowModal() == wx.ID_OK:
print "You chose %s" % dlg.GetPath()
dlg.Destroy()
this always prints :You chose /home/loai
thanks
I have had the same problem with my own code and with the code posted above. However, I discovered that there is a way around it. When you use DirDialog, do not actually navigate into the directory you want to open. Instead, just highlight the directory you want to open and click open.
On Ubuntu 12.10, with Python 2.7.3, and wxPython 2.8.12.1 (and with 2.9), navigating all the way into a directory and clicking the open button just gives you your home directory. Navigating one directory up, highlighting the desired directory, and clicking the open button gives the correct result.
I have another machine running ubuntu 11.10 with Python 2.7.3 and I don’t remember having this problem.
Clearly, this work around is not a proper solution but it’s all I’ve been able to come up with so far. I hope it helps.