sizer question

Greetings,

I have a grid control in a panel and two other panels in the frame. I generate the grid dynanmically and would like to set the size of the frame such that grid is exactly fit and there are no scrollers. How do I do this?

Yes, I am using sizers. But I got a feeling that whatever I do with sizers, it’s not going to change the size of my main frame and I would like to do that based up on the size of the grid. Then I tried reading the size of the grid using grid.GetSize() and it returns the current size of the grid. How do you get the expanded size(with no scrollers) of a grid if I want to use this size to enforce size of the frame.

Thanks in advance,

Ananda

I guess you have to set to do something like this:
grid.SetMinSize(grid.GetSize())
Afterwards you have to layout and fit your main frame again.
Stani

···

--

Ananda Regmi wrote:

Greetings,

I have a grid control in a panel and two other panels in the frame. I
generate the grid dynanmically and would like to set the size of the frame
such that grid is exactly fit and there are no scrollers. How do I do this?

Yes, I am using sizers. But I got a feeling that whatever I do with sizers,
it's not going to change the size of my main frame and I would like to do
that based up on the size of the grid. Then I tried reading the size of the
grid using grid.GetSize() and it returns the current size of the grid. How
do you get the expanded size(with no scrollers) of a grid if I want to use
this size to enforce size of the frame.

Thanks in advance,

Ananda

Thanks for the response Stani…

Would you mind elaborating a little on “Afterwards you have to layout and fit your main frame again.”

Ananda

···

On 6/21/07, Stani’s Python Editor spe.stani.be@gmail.com wrote:

I guess you have to set to do something like this:
grid.SetMinSize(grid.GetSize())
Afterwards you have to layout and fit your main frame again.
Stani

http://pythonide.stani.be

Ananda Regmi wrote:

Greetings,

I have a grid control in a panel and two other panels in the frame. I
generate the grid dynanmically and would like to set the size of the frame

such that grid is exactly fit and there are no scrollers. How do I do this?

Yes, I am using sizers. But I got a feeling that whatever I do with sizers,
it’s not going to change the size of my main frame and I would like to do

that based up on the size of the grid. Then I tried reading the size of the
grid using grid.GetSize() and it returns the current size of the grid. How
do you get the expanded size(with no scrollers) of a grid if I want to use

this size to enforce size of the frame.

Thanks in advance,

Ananda


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Probably something like this (self=frame), supposing that the grid is in
the first sizer of your frame:
self.grid.SetMinSize(self.grid.GetVirtualSize())
self.SetMinSize(self.GetSizer().GetMinSize())
self.Fit()

The size you are after is the virtual size, which you want to match with
the visible client size. (So this was wrong in my first post.)

Stani

···

--

Ananda Regmi wrote:

Thanks for the response Stani..

Would you mind elaborating a little on "Afterwards you have to layout and
fit your main frame again."

Ananda

On 6/21/07, Stani's Python Editor <spe.stani.be@gmail.com> wrote:

I guess you have to set to do something like this:
grid.SetMinSize(grid.GetSize())
Afterwards you have to layout and fit your main frame again.
Stani
--
http://pythonide.stani.be

Ananda Regmi wrote:
> Greetings,
>
> I have a grid control in a panel and two other panels in the frame. I
> generate the grid dynanmically and would like to set the size of the
frame
> such that grid is exactly fit and there are no scrollers. How do I do
this?
>
> Yes, I am using sizers. But I got a feeling that whatever I do with
sizers,
> it's not going to change the size of my main frame and I would like to
do
> that based up on the size of the grid. Then I tried reading the size of
the
> grid using grid.GetSize() and it returns the current size of the grid.
How
> do you get the expanded size(with no scrollers) of a grid if I want to
use
> this size to enforce size of the frame.
>
> Thanks in advance,
>
> Ananda
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Ananda Regmi wrote:

Greetings,

I have a grid control in a panel and two other panels in the frame. I
generate the grid dynanmically and would like to set the size of the
frame such that grid is exactly fit and there are no scrollers. How do I
do this?

I think, this is tricky. At least you can't do that only by relying on the
sizing mechanism of sizers. See that thread:

http://thread.gmane.org/gmane.comp.python.wxpython/34427/focus=34521

I once solved that like this:

size = 0
for c in range(self.GetNumberCols()):
     size += self.GetColSize(c)
size += self.GetRowLabelSize()+1

self.SetSizeHints(size,-1)
self.SetMinSize((size, -1))

where self is a wx.Grid

Christian

Thanks Christian…

It worked great.

···

On 6/22/07, Christian K ckkart@hoc.net wrote:

Ananda Regmi wrote:

Greetings,

I have a grid control in a panel and two other panels in the frame. I
generate the grid dynanmically and would like to set the size of the
frame such that grid is exactly fit and there are no scrollers. How do I

do this?

I think, this is tricky. At least you can’t do that only by relying on the
sizing mechanism of sizers. See that thread:


http://thread.gmane.org/gmane.comp.python.wxpython/34427/focus=34521

I once solved that like this:

size = 0
for c in range(self.GetNumberCols()):
size += self.GetColSize(c)
size += self.GetRowLabelSize
()+1

self.SetSizeHints(size,-1)
self.SetMinSize((size, -1))

where self is a wx.Grid

Christian


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org