Newbie help on wxPython

jsnyder trelis at
Tue Sep 4 00:08:55 CEST 2001

I'm working with the wxPython tutorial and have a problem with this code for
opening a file dialog:

def OnOpen(self,e):
->    dlg=wxFileDialog(self, "Choose a file", self.dirname, "","*.*",
        if dlg.ShowModal()==wxID_OK:
            self.dirname =dlg.GetDirectory()
->         f=open(os.path.join(self.dirname,self.filename),'r')

In the call to wxFileDialog, using the self.dirname call from the os module
results in the error below, using the same call later in the open() works
just fine.

Traceback (most recent call last):
  File "C:\Python21\SampleEditor.pyw", line 46, in OnOpen
    dlg=wxFileDialog(self, "Choose a file", self.dirname, "","*.*", wxOPEN)
AttributeError: MainWindow instance has no attribute 'dirname'

Any ideas?  TIA.

Joe Snyder

More information about the Python-list mailing list