[wxruby-users] set_size doesn't work inside initialize block
Alex Fenton
alex at pressure.to
Sun Mar 1 13:41:17 EST 2009
David Peoples wrote:
> I'm putting a ListCtrl in a Frame, creating the ListCtrl during
> Frame.initialize(). I want to adjust the ListCtrl's height to fit the
> number of rows the control contains, not just hardcode the height
> (presuming the control's font will be different on different systems).
You're using Sizers, which means you're renouncing explicitly setting
pixel size in favour of allowing the sizer to manage platform
differences and the user resizing the window. This is probably why your
set_size call isn't working.
If you want to control the height allocated to the ListCtrl within the
sizer, specify its minimum size like this:
@list_ctrl.min_size = 200, 200
And add it to the sizer with a proportion of 0 (ie, minimum size only) -
as you have at the moment. Whenever you need to change the height, just
call min_size= again, and then layout() the sizer.
a
More information about the wxruby-users
mailing list