DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Gathering Wxpy widgets (http://www.daniweb.com/forums/thread158254.html)

evstevemd Nov 19th, 2008 4:53 am
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!

          
        #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()

vegaseat Nov 19th, 2008 11:50 am
Re: Gathering Wxpy widgets
 
Of hand, I would say main vertical sizer mains is missing.

evstevemd Nov 19th, 2008 3:32 pm
Re: Gathering Wxpy widgets
 
I forgot to say that, that is a part of code; May be I have to post full code!

evstevemd Nov 19th, 2008 3:43 pm
Re: Gathering Wxpy widgets
 
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()


All times are GMT -4. The time now is 4:34 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC