Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wx.app object must be created first

My code is pretty straight forward, but I keep getting the error below. I researched the error and it pretty much says IDLE and my own GUI are screwing each other up, but I don't really know how to avoid it. I mean, if I just click on the .py file for my GUI without having IDLE open, I get the same error.

Any ideas?

Python 2.7 Windows XP

import wx

class applicationName(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Title', size=(300,200))
        panel = wx.Panel(self)


    box = wx.TextEntryDialog(None, "How old are you?", "Title", "default text")
    if box.ShowModal() == wx.ID_OK:
        answer = box.GetValue()




if __name__ =='__main__':
    app = wx.PySimpleApp()
    frame = applicationName(parent=None, id=-1)
    frame.Show()
    app.MainLoop()

Error:

PyNoAppError: The wx.App object must be created first!


like image 597
jerry Avatar asked Dec 01 '22 02:12

jerry


1 Answers

I guess you encountered this problem when you were debugging your program second time.

You can add the line at the end of the code.

del app

I hope it can help you.

like image 88
wicos Avatar answered Dec 04 '22 03:12

wicos