A simple way to create a Hello World program:
import wx
app = wx.App(redirect=False)
frame = wx.Frame(parent=None, id=wx.ID_ANY, title='Hello World')
frame.Show()
app.MainLoop()
Output:
A more typical example would be to subclass wx.Frame:
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title='Hello World')
self.Show()
if __name__ == '__main__':
app = wx.App(redirect=False)
frame = MyFrame()
app.MainLoop()
This can also be rewritten to use Python's super:
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwargs):
"""Constructor"""
super(MyFrame, self).__init__(*args, **kwargs)
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = MyFrame(None, title='Hello World')
app.MainLoop()