Start New Discussion within our Software Development Community

Hi! This is my first post on this web, so I hope not to be making a dumb question :P. I've been messing with a program for a while, and recently I migrated my code to the 2.5.2. Once I did it my code keeps on giving me the PyNoAppError. This is my code:

class wxTheApp(wx.App):

def OnInit(self):
frame = wxMainFrame(None, title="Test")
frame.Show()
self.SetTopWindow(frame)
return True

if __name__ == "__main__":
app = wxTheApp()
app.MainLoop()

And, once inside the MainFrame, I create several more frames, like this:
mynewframe = wxMyNewFrame(self,-1,(0,0),(10,10))

Then, when the _init_ of the frame is called, I receive the error. As far as I can see this error is due to the new policy in frames and windows about the detection of an App running. Someone knows how to fix it? (the code worked before the update).
Thanks in advance for any suggestion ^^

PD: sorry about my grammar

This works just fine with Python2.5.2 and wxPython2.8.8.0 ...

# create a wxPython application with OnInit()
# IMHO somewhat oldfashioned!

import wx

class MyFrame(wx.Frame):
    """inherits wx.Frame"""
    def __init__(self, parent, id, title):
        # first call base class __init__ method to create the frame
        wx.Frame.__init__(self, parent, id, title)


class MyApp(wx.App):
    """inherits wx.App"""
    def OnInit(self):
        # wxPython calls this method to initialize the application
        # create an instance of our customized Frame class
        frame = MyFrame(None, -1, "This is a test")
        frame.Show(True)
        # tell wxPython that this is our main window
        self.SetTopWindow(frame)
        # return an optional success flag
        return True


app = MyApp(0)
app.MainLoop()
This article has been dead for over six months. Start a new discussion instead.