Re: wxPython problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stef Mientki

    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\pyt honw.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(TopLevelW indow):
    """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=EmptyStri ng,
    Point pos=DefaultPosi tion, Size size=DefaultSiz e,
    long style=DEFAULT_F RAME_STYLE, String name=FrameNameS tr) -Frame
    """
    >
    # The following line is highlighted as where the error occures
    >
    _windows_.Frame _swiginit(self, _windows_.new_F rame(*args, **kwargs))
    self._setOORInf o(self)
    >
    >
    RUNNING THE SIMPLE.PY SCRIPT FROM WITHIN IDLE PRODUCES THE FOLLOWING
    ERROE MESSAGE:
    >
    Traceback (most recent call last):
    File "C:\Documen ts and Settings\Peter\ My Documents\Dev\P ython\WxPython
    Tutorial\absolu te.py", line 28, in <module>
    Absolute(None, -1, '')
    File "C:\Documen ts and Settings\Peter\ My Documents\Dev\P ython\WxPython
    Tutorial\absolu te.py", line 9, in __init__
    wx.Frame.__init __(self, parent, id, title, size=(250, 180))
    File
    "C:\Python25\Li b\site-packages\wx-2.8-msw-unicode\wx\_win dows.py",
    line 505, in __init__
    _windows_.Frame _swiginit(self, _windows_.new_F rame(*args, **kwargs))
    PyNoAppError: The wx.App object must be created first!
    >
    >
Working...