[wxPython] Sizers problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Sizers problem

IvO-3
Hi,

I have a FlexGridSizer inside a notebook page (a wxPanel). The I add
widgets to the page ...


def OnSize(self, evt):
        print "Size event"
        self.Layout()

def AddDbFields(self):
        id = 1000

        self.grid = wxFlexGridSizer(4,4,5,5)
        self.SetSizer(self.grid)
        EVT_SIZE(self, self.OnSize)

        #self.box = wxBoxSizer(wxHORIZONTAL)
       

        self.ID = wxTextCtrl(self, id+APOD_ID)
        self.NOMBRE = wxTextCtrl(self, id+APOD_NOMBRE)
        self.RUT = wxTextCtrl(self, id+APOD_RUT)
        self.APELLIDOS = wxTextCtrl(self, id+APOD_APELLIDOS)
        self.DIR1 = wxTextCtrl(self, id+APOD_DIR1)
        self.DIR2 = wxTextCtrl(self, id+APOD_DIR1)
        self.CIUDAD = wxTextCtrl(self, id+APOD_CIUDAD)
        self.FONO = wxTextCtrl(self, id+APOD_FONO)
        self.EFONO = wxTextCtrl(self, id+APOD_EFONO)
        self.ECONTACT = wxTextCtrl(self, id+APOD_ECONTACT)
        self.FECHA = wxTextCtrl(self, id+APOD_FECHA)
        self.SEXO = wxRadioBox(self, id+APOD_SEXO,"Sexo:",
                               wxDefaultPosition, wxDefaultSize,
                               ['M', 'F'])
       
        self.grid.AddMany([
            (wxStaticText(self, -1, "Id"),0), (self.ID,1,wxEXPAND ),
            (wxStaticText(self,-1,"Rut"),0),(self.RUT,1, wxEXPAND ),
            (wxStaticText(self,-1,"Nombre"),0),(self.NOMBRE,1),
            (wxStaticText(self,-1,"Apellidos"),0),(self.APELLIDOS,1),
            (wxStaticText(self,-1,"Dir1:"),0),(self.DIR1,1),
            (wxStaticText(self,-1,"Dir2:"),0),(self.DIR2,1),
            (wxStaticText(self,-1,"Ciudad:"),0),(self.CIUDAD,1),
            (wxStaticText(self,-1,"Fono:"),0),(self.FONO,1),
            (wxStaticText(self,-1,"Fono
de\nEmergencia:"),0),(self.EFONO,1),
            (wxStaticText(self,-1,"Contacto
de\nEmergencia:"),0),(self.ECONTACT,1),
            (wxStaticText(self,-1,"Fecha:"),0),(self.FECHA,1),
            (wxStaticText(self,-1,"Sexo:"),0),(self.SEXO,1),
            ])

        self.grid.Fit(self)
        self.grid.SetSizeHints(self)


        So far it was fairly well but the TextCtrl do not expand to fit the
available space, so they alway appear with minimum size ad are fix to
it.

        How can I do to make them expand to use all available space?

thanx in advance,
Saludos,
IvO

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Sizers problem

Robin Dunn
> I have a FlexGridSizer inside a notebook page (a wxPanel). The I add
> widgets to the page ...
>


>
> So far it was fairly well but the TextCtrl do not expand to fit the
> available space, so they alway appear with minimum size ad are fix to
> it.
>
> How can I do to make them expand to use all available space?

With the wxFlexGridSizer you must specify which rows and columns are
expandable, otherwise the cell the items are in will not grow.  Once the cell
is changing size then items within it with the wxEXPAND flag will grow to
fill the cell.  In your case you probably want to add:

        self.grid.AddGrowableCol(1)
        self.grid.AddGrowableCol(3)

as well as wxEXPAND flags where appropriate.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!





_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users