From: Kevin A. <al...@se...> - 2004-09-02 16:52:01
|
On Sep 2, 2004, at 8:44 AM, stephen wrote: > I'm using pythoncard 0.8 on windows. The documentation says "The > fileDialog > component returns two values, stored as elements of the Python > dictionary", > but it's returning something of type 'instance'. > > from PythonCard import model,dialog > > class Minimal(model.Background): > ....def on_menuFileExit_select(self,event): > ........self.Close() > > ....def on_menuFileOpen_select(self,event): > ........wildcard = "*" > ........encryptedfile = dialog.fileDialog(self, 'Open', '', '', > wildcard ) > ........print type(encryptedfile) > ........print encryptedfile['paths'] > > if __name__ == '__main__': > ....app = model.Application(Minimal) > ....app.MainLoop() > > and the output is: > > <type 'instance'> > Traceback (most recent call last): > File "C:\Python23\lib\site-packages\PythonCard\menu.py", line 205, > in _dispatch > handler(background, aWxEvent) > File "Display Encrypted.py", line 18, in on_menuFileOpen_select > print encryptedfile['paths'] > AttributeError: DialogResults instance has no attribute '__getitem__' > > _________ > Stephen Sorry, I missed that paragraph when I was updating the dialog docs. As the migration guide mentions, all results are now an instance of DialogResults and where you previously accessed a dictionary key, you now just use an attribute. So, instead of encryptedfile['paths'] used encryptedfile.paths http://pythoncard.sourceforge.net/migration_guide.html ka |