why "import wx" doesn't work?
Kartic
removethis.kartic.krishnamurthy at gmail.com
Thu Apr 28 17:59:35 EDT 2005
The Great 'monkey' uttered these words on 4/28/2005 5:30 PM:
> It is the current version of wxPython(2.6). But follow you instruction it
> still can't work...
> But if using the default "from wxPython.wx import *", it work, don't know
> what is the problem. May be this is an old example that cannot work with
> "import wx". Because I get another example and it is ok.
>
I suspect you are mixing program code for the namespace version (import
wx) with the old method of importing (from wxPython.wx import *).
Here are two version of a very simple app... try both and see if you get
any errors. And if so, _please_ post the exact error you get.
--- BEGIN The "new" namespace version ----
import wx
class MainFrame(wx.Frame):
def __init__(self, parent, id=-1, title="Test Wx", size=(-1, -1),
pos=(-1,-1), style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE):
wx.Frame.__init__(self, parent, id, title, size, pos, style)
self.Show(True)
app = wx.PySimpleApp()
frame = MainFrame(None, -1, "Test Wx NameSpace Style")
app.MainLoop()
--- END The "new" namespace version ----
--- BEGIN The old style import ----
from wxPython.wx import *
class MainFrame(wxFrame):
def __init__(self, parent, id=-1, title="Test Wx", size=(-1, -1),
pos=(-1,-1), style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE):
wxFrame.__init__(self, parent, id, title, size, pos, style)
self.Show(True)
app = wxPySimpleApp()
frame = MainFrame(None, -1, "Test Wx Old Style")
app.MainLoop()
--- END The old style import ----
Hope that helped!
Thanks,
-Kartic
More information about the Python-list
mailing list