Sunday, May 6, 2007, 3:21:16 AM, krishnakant Mane wrote:
although I did not understand the parameters you passed to the
spacer. I understood the row and comumn but what was before that in
the nested ()? was that the left and top size of the spacer or top
and left? you see, I am a blind person and can't make a guess, so
want to know. actually I am also doing my research on how blind
people can create good layouts and I think the gridbag was pritty
good enough.
The line
sizer.AddSpacer((50, 10), pos=(row, 0))
is adding a 50x10 (50 pixels x 10 pixels) empty space to the row 'row'
and column 0 of the sizer.
and the line
sizer.Add(st, pos=(row, 1), border=20,
flag=wx.TOP|wx.ALIGN_CENTRE_VERTICAL|wx.ALIGN_LEFT)
is adding 'st' (the StaticText) to the row 'row' and column 1 of the
sizer. The StaticText will be aligned to the left and will be centered
vertically in the grid. That grid cell will also have a 20 pixel
height border on the top, i. e., a 20 px empty space separating the
StaticText and the top of the grid cell.
second thing I wanted to understand is that when u added the
horizontal box, I think you have given the span option, can you
explain that? is it to say that this particular box will occupy the
entire row?
Yes.
does it start from 0 or 1?
Positions always start from 0.
Spans always start from 1. So that a 'span=(1,1)' is redundant, and
'span=(0,x)' or 'span=(x,0)' are errors.
A GridBagSizer showing the 'pos' (position) parameters; no cell was
spanned:
···
+-------+-------+-------+
(0,0) | (0,1) | (0,2) |
+-------+-------+-------+
(1,0) | (1,1) | (1,2) |
+-------+-------+-------+
(2,0) | (2,1) | (2,2) |
+-------+-------+-------+
A GridBagSizer where the (1,0) position was spanned to occupy 1 row
and 3 columns:
+-------+-------+-------+
(0,0) | (0,1) | (0,2) |
+-------+-------+-------+
(1,0), span=(1,3) |
+-------+-------+-------+
(2,0) | (2,1) | (2,2) |
+-------+-------+-------+
Another GridBagSizer where the (1,1) position was spanned to occupy 2
rows and 2 columns:
+-------+-------+-------+-------+
> > > >
+-------+-------+-------+-------+
> (1,1), | |
+-------+ span=(2,2) +-------+
> > >
+-------+-------+-------+-------+
> > > >
+-------+-------+-------+-------+
I also want to know what is basic difference between a flexgrid and
gridbag layout.
I strongly recommend you to that a look at the docs, since they
explains that better than me.
Quoting the docs:
"""
A FlexGridSizer is a sizer which lays out its children in a
two-dimensional table with all table fields in one row having the same
height and all fields in one column having the same width, but all
rows or all columns are not necessarily the same height or width as in
the wxGridSizer.
GridBagSizer is a wxSizer that can lay out items in a virtual grid
like a wxFlexGridSizer but in this case explicit positioning of the
items is allowed using wxGBPosition, and items can optionally span
more than one row and/or column using wxGBSpan.
"""
Also, I strongly recommend you to donwload and install the wxPython
Demo. It has several examples on how to use everything in wxPython,
including sizers:
http://www.wxpython.org/download.php
The wiki is also your friend. There are a lot of helpful pages
regarding sizers, for example:
http://wiki.wxpython.org/index.cgi/UsingSizers
http://wiki.wxpython.org/index.cgi/wxSizer_in_python
http://wiki.wxpython.org/index.cgi/wxGridBagSizer
can I also set the minimum and maximumn sizes of controls like I can
do in box layouts? if yes then how?
Yes. You do that in the control itself, via SetMinSize and
SetMaxSize methods.
-- tacao
No bits were harmed during the making of this e-mail.