472,111 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,111 software developers and data experts.

Re: wxPython problem

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!

Sep 6 '08 #1
0 1686

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Daniel Ehrenberg | last post: by
7 posts views Thread by SeeBelow | last post: by
1 post views Thread by timothy.williams | last post: by
1 post views Thread by James Stroud | last post: by
reply views Thread by Robin Dunn | last post: by
6 posts views Thread by Robin Dunn | last post: by
reply views Thread by Robin Dunn | last post: by
2 posts views Thread by Marco | last post: by
4 posts views Thread by stef | last post: by
8 posts views Thread by Sean DiZazzo | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.