[wxruby-users] RES: Problem centering a label
Alex Fenton
alex at pressure.to
Fri Mar 20 11:02:48 EDT 2009
Hi
Christian Schmidt wrote:
> super( parent, 1011, {:style => SIMPLE_BORDER, :name
> =>"NovaTarefa"} );
>
> box = Wx::BoxSizer.new(Wx::HORIZONTAL);
> box.add_stretch_spacer();
> box.add Wx::StaticText.new(self, -1, 'asdf'), 0, 1
> box.add_stretch_spacer();
>
>
Simpler, using StaticText ALIGN styles instead of extra spacers
box = Wx::VBoxSizer.new
st = Wx::StaticText.new(self, :label => 'adsf', :style => Wx::ALIGN_CENTRE)
box.add st, 0, Wx::GROW
> Watch for the parents' constructor - you needn't set size and position.
>
This is a good point - use sizers to have children adjust to their
parent's size. Also, if a window is the only child of a frame parent
(often the case with Panels inside Frames) then it will automatically
take up all the avaiable space - no sizer needed.
a
More information about the wxruby-users
mailing list