wxPython problem

Stef Mientki stef.mientki at gmail.com
Sat Sep 6 11:28:28 CEST 2008


Peter Anderson wrote:
> I am trying to teach myself how to program in Python and use wxPython 
> for GUIs. I am using PyScripter, IDLE and EditPlus as my IDEs. I have 
> experienced an odd problem where I run a script once and it runs fine. 
> Run it again and I get an error and the script fails.
>
> If the script is run directly from Python ('Run' from Windows 
> Explorer) or from EditPlus (in which I have a "user-defined tool" 
> which calls C:\Python25\pythonw.exe with the parameter of $(FileName)) 
> then there is *never* any error, no matter how many times the script 
> is run.
>
> Close down PyScripter or IDLE and then start either up again, load the 
> script and run it - it runs fine. Run it again and it fails. It seems 
> like something is already set in memory and cant be re-set (my lack of 
> knowledge is showing here :-( ).
>
In PyScripter, you should run wxPython in the plain remote machine (not 
the wxPython remote),
and you should set "reset before run flag" or reset the remote machine 
each time yourself.

cheers,
Stef
> More details are shown below. Any help or hints would be greatly 
> appreciated.
>
> Regards,
> Peter
>
>
> RUNNING SIMPLE.PY (AND OTHER SCRIPTS USING WXPYTHON) FROM PYSCRIPTER I 
> GET THE FOLLOWING ERROR MESSAGE:
>
> PyNoAppError: The wx.App object must be created first!
>
> PyScripter loads a module (I presume from wxPython) called _windows.py 
> and highlights a particular line in red and displays the error message 
> from above. I have Googled the error message but the results have not 
> helped.
>
>
> LISTING FOR SIMPLE.PY
>
> #!/usr/bin/python
>
> # simple.py
>
> import wx
>
> app = wx.App()
>
> frame = wx.Frame(None, -1, 'simple.py')
> frame.Show()
>
> app.MainLoop()
>
>
> EXERPT FROM _WINDOWS.PY - PYSCRIPTER HIGHLIGHTS SECOND LAST LINE
>
> class Frame(TopLevelWindow):
> """Proxy of C++ Frame class"""
> thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), 
> doc='The membership flag')
> __repr__ = _swig_repr
> def __init__(self, *args, **kwargs):
> """
> __init__(self, Window parent, int id=-1, String title=EmptyString,
> Point pos=DefaultPosition, Size size=DefaultSize,
> long style=DEFAULT_FRAME_STYLE, String name=FrameNameStr) -> Frame
> """
>
> # The following line is highlighted as where the error occures
>
> _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
> self._setOORInfo(self)
>
>
> RUNNING THE SIMPLE.PY SCRIPT FROM WITHIN IDLE PRODUCES THE FOLLOWING 
> ERROE MESSAGE:
>
> Traceback (most recent call last):
> File "C:\Documents and Settings\Peter\My Documents\Dev\Python\WxPython 
> Tutorial\absolute.py", line 28, in <module>
> Absolute(None, -1, '')
> File "C:\Documents and Settings\Peter\My Documents\Dev\Python\WxPython 
> Tutorial\absolute.py", line 9, in __init__
> wx.Frame.__init__(self, parent, id, title, size=(250, 180))
> File 
> "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", 
> line 505, in __init__
> _windows_.Frame_swiginit(self,_windows_.new_Frame(*args, **kwargs))
> PyNoAppError: The wx.App object must be created first!
>
>




More information about the Python-list mailing list