why "import wx" doesn't work?

Peter Hansen peter at engcorp.com
Thu Apr 28 15:56:55 EDT 2005


monkey wrote:
> I just learn to make a blank windows frame with python and wxpython. I found
> the statment "import wx" cannot work as the original "from wxPython.wx
> import *". I see in the readme file of wxpython that if I install it as the
> default one, I can use "import wx" instead of the long one. What is wrong?
> The code pasted below:
> 
> import wx   # the default is "from wxPython.wx import *", I change it and it
> just can't work.
> 
> class MyApp(wxApp):
...

Assuming you've installed a version of wxPython that is recent enough 
that "import wx" works (it's really unclear from what you've written 
above), then the problem you are facing is not using the namespace that 
you've now imported.  Do this instead:

class MyApp(wx.App):
     def OnInit(self):
         frame = wx.Frame(NULL, -1, "....


Note that "wx." before everything from wxPython...

-Peter



More information about the Python-list mailing list