Zack
Zack

Reputation: 4375

wxPython: How do you specify the width of a specific column using one of the wx.sizer classes?

I'm attempting to set up something like this: enter image description here

However, I'm having a bunch of trouble in figuring it out. I made this general purpose function to wrap a list of objects in a wx.gridsizer, and then add that to a wx.StaticBoxSizer to get the border around everything. Then it return the staticBox sizer to main to be added to the main vertical boxsizer.

def buildHorizontalSizer(self, objects, label=None):
    if label:
        box = wx.StaticBox(self.panel, -1, label)
        # for i in dir(box):
        #   print i
        sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
    else:
        sizer = wx.BoxSizer(wx.HORIZONTAL)

    grid = wx.GridBagSizer(hgap=3, vgap=0)
    for i in range(len(objects)):
        if i==0:
            grid.Add(objects[i], flag=wx.ALIGN_RIGHT)
        else:
            grid.Add(objects[i], flag=wx.ALIGN_LEFT)
    sizer.Add(grid)
    return sizer

In each field, from left to right, there is a StaticText, TextCtrl, and then a Button.

How do I configure the cells so that they have different widths?

Upvotes: 3

Views: 2997

Answers (1)

Joran Beasley
Joran Beasley

Reputation: 113948

use

objects[i].SetMinSize((width,height))

Should do what you want ... you may have to also call

objects[i].SetSize((width,height))

before adding it to the sizer

Upvotes: 2

Related Questions