Newbie help on wxPython

Dirk Collins res04tzu at gte.net
Tue Sep 4 00:17:51 EDT 2001


dlg=wxFileDialog(self, "Choose a file", self.dirname, "","*.*", wxOPEN)

Why is there no parenthesis around self.dirname in your 1st line?

jsnyder wrote:

> 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, "","*.*",
> wxOPEN)
>         if dlg.ShowModal()==wxID_OK:
>             self.filename=dlg.GetFilename()
>             self.dirname =dlg.GetDirectory()
> ->         f=open(os.path.join(self.dirname,self.filename),'r')
>             self.control.SetValue(f.read())
>             f.close()
>         dlg.Destroy()
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010904/5023d5ca/attachment.html>


More information about the Python-list mailing list