BrotherJack
BrotherJack

Reputation: 329

wxPython Error in Opening Files in Ubuntu

I'm working on this tutorial and I noticed that this code snippet has a problem with it:

def OnOpen(self, e):
    """To open d' files"""
    self.dirname = ""
    dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", "*.*", wx.OPEN)
    if dlg.ShowModal() == wx.ID_OK:
        self.filename = dlg.GetFilename()
        self.dirname = dlg.GetDirectory()
        f = open(os.path.join(self.dirname, self.filename))
        self.control.SetValue(f.read())
        f.close()
    dlg.Destroy()

I'm running the code in Ubuntu 11.10 and it works as intended as long as you don't attempt to pick a file from the search or recently opened file features. Apparently it isn't receiving the directory in those cases, as self.dirname is None. I'm wondering what is happening in GetFilename and how Linux is returning the file directories in the dialog when search or recently used files are selected.

Any insight on this would be appreciated. Also, if there is anyplace to find the specific code would be appreciated. I know that it is on my drive, but I have no idea what file its in.

Upvotes: 1

Views: 256

Answers (1)

ChrisC
ChrisC

Reputation: 1272

Isn't GetPath the function you'd want to use to get the path and filename of the selected file?

Upvotes: 3

Related Questions