why "import wx" doesn't work?

Filip Dreger fdreger at amiga.pl
Thu Apr 28 19:20:45 EDT 2005


U¿ytkownik "monkey" <m at m.com> napisa³ w wiadomo¶ci 
news:42715a8b$1_1 at rain.i-cable.com...
>> Which version of wxPython are you running? What do you mean by 
>> "does not
>> work"...does the import fail or is your code giving errors?
>
> It is the current new version 2.6. The error message said that the 
> class
> wxApp is not defined...

This is very good! wxApp is never defined if you use "import wx". You 
must use "wx.wxApp" instead.

If you import a module using "import anything", then all the names 
imported from the module must begin with "anything.". If you import wx 
using "import wx", then ALL the wx commands, classes and variables 
(all the names) MUST begin with 'wx.". Change them, and your program 
will work.

"from wx import *" is a special shortcut, allowing you to use all the 
names without "wx.". If you change "from something import *" to 
"import something", your code will always break, this is normal.

regards,
Filip Dreger 





More information about the Python-list mailing list