| | |
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 |
accessdenied advanced aliased anydbm app beginner bits calling casino cipher clear command conversion convert coordinates corners count csv cturtle cursor curves def definedlines development dynamic dynamically event events excel feet file float format frange function google handling homework i/o iframe input jaunty keyboard keycontrol lapse line linux list lists loan loop matching mouse multiple newb number numbers obexftp output parsing path prime programming projects py py2exe pygame pymailer pyopengl python random rational raw_input recursion recursive return searchingfile signal string strings tails text time tlapse tooltip tuple type ubuntu unicode url urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython xlwt






