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 :-( ).
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!
--
*Peter Anderson*
There is nothing more difficult to take in hand, more perilous to
conduct, or more uncertain in its success, than to take the lead in the
introduction of a new order of things—Niccolo Machiavelli, /The Prince/,
ch. 6
--
http://mail.python.org/mailman/listinfo/python-list