[wxPython-users] how to force wxGrid in sizer to show all columns?
Robin Dunn
robin at alldunn.com
Mon Oct 1 12:55:11 PDT 2007
JJ wrote:
> Hello:
> Thanks for the previous help, particularly to Robin.
> And while Im at it, Robin thanks for the book--it
> would be more difficult for a beginner like me without
> it. I have three vertical BoxSizers placed in a
> horizontal BoxSizer. In one vertical BoxSizer is a
> wxGrid and I would like the grid to show all its
> columns (i.e., no scroll).
You'll probably need to write some code that adjusts the grid column
widths to fill the space given the grid. Check the wiki and also the
list archives as this has been discussed before so there are probably
some examples somewhere.
> If any extra room is left,
> I would like the spacing between vertical sizers to
> adjust accordingly. The following code works except
> that not all columns of the wxGrid are shown. Can
> anyone tell me where I am going wrong? I dont want to
> set the size of the wxGrid by hand (I'd like it to
> size automatically).
Part of the problem is how you are using the sizers. You are Fit()ing
the panel to be large enough to show all the widgets, but you are not
doing anything to the frame to make it large enough. So the grid is
drawn off the edge of the frame and you can't see some of it unless you
make the frame larger. One way to handle this is to do this instead of
your SetSizerAndFit:
panelA.SetSizer(mainBoxSizer)
mainBoxSizer.SetSizeHints(self)
That will not only make the frame start out to be large enough to show
all the widgets as dictated by the sizer, but will also limit it from
being resized too small.
>
> Also, note that if you maximize the frame, there will
> be an ugly white block to the right of the wxGrid. Im
> just curious if there is a way to get rid of that.
It is not to the right of the grid, it is the grid. That is simply how
the grid displays itself when its size is larger than the width of its
columns. Since you are putting it into the sizer with a proportion of 1
then the sizer will give it an equal share of all the extra space, so it
will size the grid larger and larger as you resize the containing window.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list