[wxPython-users] PyNoAppError when Run the second time?

Robin Dunn robin at alldunn.com
Mon Nov 19 21:58:39 PST 2007


Davy wrote:
> Hi all,
> 
> My environemt is Python2.5 +  wxPython 2.8.6.1 + PythonWin (all version are 
> latest).
> 
> I have copied a program from "Getting Started"
> ##------------
> import wx
> app = wx.PySimpleApp()
> frame = wx.Frame(None, wx.ID_ANY, "Hello World")
> frame.Show(True)
> app.MainLoop()
> ##------------
> 
> When I run the first time, the program is OK.
> But when I run the second time, the program raise a exception:
> 
> Traceback (most recent call last):
>   File "C:\Python25\works\wxPython\test.py", line 3, in <module>
>     frame = wx.Frame(None, wx.ID_ANY, "Hello World")
>   File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 
> 501, in __init__
>     _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
> PyNoAppError: The wx.App object must be created first!
> 
> Is my code right? Any suggestions are welcome!

PythonWin runs code in the same Python process that the IDE is running 
in, and wxWidgets assumes that there will only ever be one wxApp in the 
process, so things get a little tricky when we try to force it.  In 
either case you'll be better off not running wx apps from within 
PythonWin.  Choose an IDE that runs the code in external processes, or 
run from the command-line.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list