Advertisement
Guest User

wx tut

a guest
Dec 5th, 2012
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. import wx
  2.  
  3. class MyForm(wx.Frame):
  4.  
  5.     def __init__(self):
  6.         wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial")
  7.  
  8.         # Add a panel so it looks the correct on all platforms
  9.         panel = wx.Panel(self, wx.ID_ANY)
  10.  
  11.         # create the labels
  12.         lblOne = wx.StaticText(panel, label="labelOne", size=(60,-1))
  13.         lblTwo = wx.StaticText(panel, label="lblTwo", size=(60,-1))
  14.         lblThree = wx.StaticText(panel, label="lblThree", size=(60,-1))
  15.  
  16.         # create the text controls
  17.         txtOne = wx.TextCtrl(panel)
  18.         txtTwo = wx.TextCtrl(panel)
  19.         txtThree = wx.TextCtrl(panel)
  20.         buttonFour = wx.Button(panel)
  21.  
  22.         # create some sizers
  23.         mainSizer = wx.BoxSizer(wx.VERTICAL)
  24.         lineOneSizer = wx.BoxSizer(wx.HORIZONTAL)
  25.         lineTwoSizer = wx.BoxSizer(wx.HORIZONTAL)
  26.         lineThreeSizer = wx.BoxSizer(wx.HORIZONTAL)
  27.  
  28.         # add widgets to sizers
  29.         lineOneSizer.Add(lblOne, 0, wx.ALL|wx.ALIGN_LEFT, 5)
  30.         lineOneSizer.Add(txtOne, 1, wx.ALL, 5)
  31.         lineTwoSizer.Add(lblTwo, 0, wx.ALL|wx.ALIGN_LEFT, 5)
  32.         lineTwoSizer.Add(txtTwo, 0, wx.ALL, 5)
  33.         lineThreeSizer.Add(lblThree, 0, wx.ALL|wx.ALIGN_LEFT, 5)
  34.         lineThreeSizer.Add(txtThree, 0, wx.ALL, 5)
  35.         lineThreeSizer.Add(buttonFour, 0, wx.ALL, 5)
  36.        
  37.  
  38.         mainSizer.Add(lineOneSizer)
  39.         mainSizer.Add(lineTwoSizer)
  40.         mainSizer.Add(lineThreeSizer)
  41.  
  42.         panel.SetSizer(mainSizer)
  43.  
  44.        
  45.  
  46. # Run the program
  47. if __name__ == "__main__":
  48.     app = wx.App(False)
  49.     frame = MyForm()
  50.     frame.Show()
  51.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement