| | |
Gathering Wxpy widgets
![]() |
I have code but when I want to gather my widgets under same wx.StaticBox I fail. I wonder what is wrong! Please someone to corrrect me!
python Syntax (Toggle Plain Text)
#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()
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
python Syntax (Toggle Plain Text)
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()
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
![]() |
Other Threads in the Python Forum
- Previous Thread: File formats
- Next Thread: archiver
| Thread Tools | Search this Thread |
abrupt ansi anti apache approximation array assignment avogadro backend beginner binary bluetooth book builtin calculator character cmd converter countpasswordentry curved customdialog dan08 decimals dictionaries dictionary dynamic error exe file float format function gnu graphics heads homework http ideas import inches input java leftmouse library line lines linux list lists loop module mouse mysqlquery number numbers numeric output parsing path phonebook plugin pointer prime programming progressbar py2exe pygame python random recursion redirect scrolledtext software sqlite statictext statistics string strings sum table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode urllib urllib2 variable wordgame write wxpython xlib






