I wrote this 2 pieces of code:
- Create a class Myframe that inherits from wx.frame and create a App and it works fine as expected.
code1.py
import wx
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None,title="MyFrame")
self.SetTopWindow(self.frame)
self.frame.Show()
return True
class MyFrame(wx.Frame):
def __init__(self,*args,**kwargs):
super(MyFrame,self).__init__(*args,**kwargs)
self.CreateStatusBar()
self.SetStatusText("Initializing")
self.CreateToolBar()
if __name__ == "__main__":
app = MyApp(False)
app.MainLoop()
- Now, I tried create a re-write the same directly calling the wx.App
code2.py
import wx
app = wx.App()
frame = wx.Frame(None,-1,"Test")
SetTopWindow(frame)
frame.show()
app.MainLoop()
Couple of things are not working as code-1.
- The window closes immediately.
- The SetTopWindow is not working..It says undeclared variable...thats correct..but How do I refer SetTopWindow ?