When to use wx.App and PySimpleApp

I do not know where and when to use wx.App and PySimpleApp

like two codes:

#!/usr/bin/env python import wx import wx.py.images as images class ToolbarFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 200)) panel = wx.Panel(self) panel.SetBackgroundColour('White') class App(wx.App): def OnInit(self): frame = ToolbarFrame(parent=None, id=-1) frame.Show() return True if __name__ == '__main__': app = App() app.MainLoop() 

and this code:

 #!/usr/bin/env python import wx class ToolbarFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 200)) panel = wx.Panel(self) panel.SetBackgroundColour('White') if __name__ == '__main__': app = wx.PySimpleApp() frame = ToolbarFrame(parent=None, id=-1) frame.Show() app.MainLoop() 

Is there any difference? another question another widget is in wx.Frame () or wx.App () as a button.

+4
source share
1 answer

There are currently practically no differences between the two classes.

When the wxPython project started, wx.PySimpleApp and wx.App had different behavior (the latter, where a lower level was defined and the default method OnInit was not set, whereas PySimpleApp was a class that could simply be created and placed to do this job ) In addition, in some versions of wxPython there was a wx.App class that had a default value of OnInit , but by default it did not call wx.InitAllImageHandlers .

Now wx.PySimpleApp remains in the API mainly because of compatibility and there is no difference between the two classes.

+4
source

All Articles