#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11

    Grouping widgets


    I am using wxpython for my gui
    i have a panel which displays no of widgets like textbox slider ect.
    I was wondering how i can group them together something like

    -Group1--------------------
    | slider |
    | textbox |
    | |
    |---------------------------
    -Group2--------------------
    | slider |
    | textbox |
    | |
    |---------------------------
    -Group3--------------------
    | slider |
    | textbox |
    | |
    |---------------------------


    please can anybody tell me how to do that in wxpython

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11

    wxStaticLine


    i know that wxStaticLine or wxstaticbox is one of the options is there any other option other than that .
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    I generally use wxGlade for designing my layouts. This uses sizers, which allow a flexible layout. I played around with it for a few minutes to get something like what you wanted - here is the generated code....

    Code:
    #!/usr/bin/env python
    # -*- coding: ISO-8859-1 -*-
    # generated by wxGlade 0.3.5.1 on Sun Feb 06 11:55:41 2005
    
    import wx
    
    class MyFrame(wx.Frame):
        def __init__(self, *args, **kwds):
            # begin wxGlade: MyFrame.__init__
            kwds["style"] = wx.DEFAULT_FRAME_STYLE
            wx.Frame.__init__(self, *args, **kwds)
            self.panel_1 = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
            self.panel_1_copy = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
            self.sizer_3_staticbox = wx.StaticBox(self.panel_1, -1, "More text here")
            self.sizer_1_staticbox = wx.StaticBox(self, -1, "")
            self.sizer_3_copy_staticbox = wx.StaticBox(self.panel_1_copy, -1, "Some text here")
            self.slider_1_copy_copy = wx.Slider(self.panel_1_copy, -1, 0, 0, 10, style=wx.SL_HORIZONTAL|wx.SL_LABELS)
            self.text_ctrl_1_copy_copy = wx.TextCtrl(self.panel_1_copy, -1, "")
            self.slider_1_copy = wx.Slider(self.panel_1, -1, 0, 0, 10, style=wx.SL_HORIZONTAL|wx.SL_LABELS)
            self.text_ctrl_1_copy = wx.TextCtrl(self.panel_1, -1, "")
    
            self.__set_properties()
            self.__do_layout()
            # end wxGlade
    
        def __set_properties(self):
            # begin wxGlade: MyFrame.__set_properties
            self.SetTitle("frame_1")
            self.SetSize((604, 344))
            self.SetBackgroundColour(wx.SystemSettings_GetSystemColour(wx.SYS_COLOUR_3DDKSHADOW))
            # end wxGlade
    
        def __do_layout(self):
            # begin wxGlade: MyFrame.__do_layout
            sizer_1 = wx.StaticBoxSizer(self.sizer_1_staticbox, wx.VERTICAL)
            sizer_3 = wx.StaticBoxSizer(self.sizer_3_staticbox, wx.VERTICAL)
            sizer_3_copy = wx.StaticBoxSizer(self.sizer_3_copy_staticbox, wx.VERTICAL)
            sizer_3_copy.Add(self.slider_1_copy_copy, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.FIXED_MINSIZE, -2147483648)
            sizer_3_copy.Add(self.text_ctrl_1_copy_copy, 1, wx.EXPAND|wx.FIXED_MINSIZE, 0)
            self.panel_1_copy.SetAutoLayout(True)
            self.panel_1_copy.SetSizer(sizer_3_copy)
            sizer_3_copy.Fit(self.panel_1_copy)
            sizer_3_copy.SetSizeHints(self.panel_1_copy)
            sizer_1.Add(self.panel_1_copy, 1, wx.EXPAND, 0)
            sizer_3.Add(self.slider_1_copy, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.FIXED_MINSIZE, -2147483648)
            sizer_3.Add(self.text_ctrl_1_copy, 1, wx.EXPAND|wx.FIXED_MINSIZE, 0)
            self.panel_1.SetAutoLayout(True)
            self.panel_1.SetSizer(sizer_3)
            sizer_3.Fit(self.panel_1)
            sizer_3.SetSizeHints(self.panel_1)
            sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
            self.SetAutoLayout(True)
            self.SetSizer(sizer_1)
            self.Layout()
            # end wxGlade
    
    # end of class MyFrame
    
    
    class MyApp(wx.App):
        def OnInit(self):
            wx.InitAllImageHandlers()
            frame_1 = MyFrame(None, -1, "")
            self.SetTopWindow(frame_1)
            frame_1.Show()
            return 1
    
    # end of class MyApp
    
    if __name__ == "__main__":
        app = MyApp(0)
        app.MainLoop()
    Dave - The Developers' Coach
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Bimingham,AL
    Posts
    68
    Rep Power
    11
    hmm..
    i guess i should try out staticbox sizer
    thank Q

IMN logo majestic logo threadwatch logo seochat tools logo