0

Can anybody help me figure out what I'm doing wrong I've very little experience with GUIs. code:

import wx
    class bucky(wx.Frame):
            #constructor
        def __init__(self,parent,id):
            wx.Frame.__init__(self,parent,id,'Frame aka window',size=(300,200))
            panel=wx.Panel(self)
            button=wx.Button(panel,label="exit",pos=(130,10),size=(60,60))
            self.Bind(wx.EVT_BUTTON, self.closebutton,button)
            self.Bind(wx.EVT_CLOSE, self.closewindow)
        def closebutton(self,event):
            self.close(True)
        def closewindow(self,event):
            self.Destroy()
    if __name__=='__main__':
        app=wx.PySimpleApp()
        frame=bucky(parent=None,id=-1)
        frame.Show()
        app.MainLoop()

Error:

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

win32ui.error: Error in Command Message handler for command ID 36864, Code 0
DeadChex
  • 4,379
  • 1
  • 27
  • 34

1 Answers1

0

This code runs for me on Windows 7 with wxPython 2.8.12.1 and Python 2.6.6. What OS and Python versions are you using? I've seen this error message from time to time when I've run my code in IDLE. If you're doing that, then don't. Tkinter's mainloop (which is what IDLE is made with) will interfere with other GUI toolkit's main loops.

There is an issue in the closebutton method in that it call a "close" method which does not exist.

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88