import wx
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
# make a panel
mpanel = wx.Panel(self, -1)
#Define main sizer
mains = wx.BoxSizer(wx.VERTICAL)
#make display window
display = wx.TextCtrl(mpanel, -1, style = wx.TE_MULTILINE)
#Add to a sizer
mains.Add(display, 1, wx.EXPAND|wx.TOP| wx.BOTTOM, 30)
#Add static box to hold related widgets--- it otherwise does nothing
holder1 = wx.StaticBox(mpanel, -1, label="Transactions", pos = (10, 10), size = (300,300))
#add box to sizer for widgets only --- This is not main sizer
wsizer = wx.BoxSizer(wx.VERTICAL)
wsizer.Add(holder1, 0, wx.EXPAND |wx.ALL, 5)
#Make widgets for transaction
#First row of widets
id_text = wx.StaticText(mpanel, -1, "Enter Product ID")
id_text_area = wx.TextCtrl(mpanel, -1)
find = wx.Button(mpanel, -1, "Find", size=(70, 30))
#Add them to hor sizer
hbox1 = wx.BoxSizer()
hbox1.Add(id_text, 0, wx.ALL, 5)
hbox1.Add(id_text_area, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
hbox1.Add(find, 0, wx.BOTTOM| wx.TOP| wx.RIGHT, 5)
#add this sizer to widgets sizer
wsizer.Add(hbox1,0, wx.EXPAND)
#add widgets sizer wsizer to main vertical sizer mains
mains.Add(wsizer, 0, wx.EXPAND)
#set sizers and Layouts
mpanel.SetSizer(mains)
mpanel.Layout()
app = wx.App(False)
f = MainWindow(None, -1, "Cash Program")
f.Center()
f.Show()
app.MainLoop()