I am trying to create a simple GUI and I have the following
code.
…Separate file for my little class …App.py
import wx
class MyApp(wx.App):
def **__init__**(*self*):
frame = wx.Frame(None, -1, *'Welcome to Elmer'*, size=(400, 200))
frame.Show(True)
SetTopWindow(frame)
return True
···
…In my main file…
import
wx # use the wxPython module
import App
an_app = App.MyApp()
an_app.MainLoop()
When I run this I get the following error.
B:\CodeWorkSpace\Python\CAD_GUI_TOOL\src>test.py
Traceback (most recent call last):
File “B:\CodeWorkSpace\Python\CAD_GUI_TOOL\src\test.py”,
line 39, in
an_app = App.MyApp()
File “B:\CodeWorkSpace\Python\CAD_GUI_TOOL\src\App.py”,
line 20, in init
frame = wx.Frame(None, -1, 'Welcome to
Elmer’, size=(400, 200))
File
“C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx_windows.py”, line
505,
in init
windows.Frame_swiginit(self,windows.new_Frame(*args, **kwargs))
wx._core.PyNoAppError: The wx.App object must be created
first!
B:\CodeWorkSpace\Python\CAD_GUI_TOOL\src>
Can anyone help? I am confused why this does not work.
By inheriting the wx.App class isn’t my MyApp object also a wx.App object?
Isn’t the wx.App constructor called at some point when my MyApp object is
created?
Thanks,
CH
Christopher Hogan
Hardware Engineer II
D
509.343.3522
M
509.993.2120
P
206.272.5555
F
509.343.3501
****www.f5.com