[wxruby-users] RES: Problem centering a label
(gmail) Alejandro Michelin Salomon
amichelins at gmail.com
Fri Mar 20 08:05:53 EDT 2009
Christian :
I say in the other mail I have a frame, brong i have a panel.
The panel is inside the main frame.
I change my code to :
class TarefasNova < Wx::Panel
def initialize(parent)
rect = parent.get_client_rect();
super( parent, 1011, Wx::Point.new( 0, 0 ), rect.get_size(),
SIMPLE_BORDER,
"NovaTarefa" );
#sizer = Wx::BoxSizer.new(Wx::VERTICAL)
box = Wx::BoxSizer.new(Wx::HORIZONTAL);
box.add_stretch_spacer();
box.add Wx::StaticText.new(self, -1, 'asdf'), 0, 1
#label = Wx::StaticText.new( self, :label => "CADASTRO DE TAREFAS
(NOVA)", :size => [250,-1] );
#box.add( label, 1, Wx::ALIGN_CENTER, 5);
box.add_stretch_spacer();
#sizer.add_item(box, 0, Wx::ALIGN_CENTER|Wx::ALL, 5);
end
end
But the text is not centered, the text is in the left.
Exist some diferences between frame and panel to user sizer?
De: wxruby-users-bounces at rubyforge.org
[mailto:wxruby-users-bounces at rubyforge.org] Em nome de Christian Schmidt
Enviada em: quinta-feira, 19 de março de 2009 19:49
Para: wxruby-users at rubyforge.org
Assunto: Re: [wxruby-users] Problem centering a label
Hi Alejandro,
you just need one sizer on your panel. Add one spacer
(sizer.add_stretch_spacer) before and one after your text.
Like so:
sizer = BoxSizer.new HORIZONTAL
sizer.add_stretch_spacer
sizer.add StaticText.new(self, -1, 'asdf'), 0, 1
sizer.add_stretch_spacer
hth,
Christian.
Alejandro Michelin salomon wrote:
> Hi
>
>
>
> I have frame.
>
> Inside i want to put a static text as title, centered.
>
> I use two sizers, one vertical an other horizontal.
>
>
>
> But title is not centered, is put to left.
>
>
>
> My code is :
>
>
>
> require 'wx';
>
>
>
> class TarefasNova < Wx::Panel
>
> def initialize(parent)
>
> rect = parent.get_client_rect();
>
>
>
> super( parent, 1011, Wx::Point.new( 0, 0 ), rect.get_size(),
> SIMPLE_BORDER, "NovaTarefa" );
>
>
>
> sizer = Wx::BoxSizer.new(Wx::VERTICAL );
>
> box = Wx::BoxSizer.new(Wx::HORIZONTAL);
>
>
>
> label = Wx::StaticText.new( self, :label => "CADASTRO DE TAREFAS
> (NOVA)", :size => [250,-1] );
>
>
>
> box.add( label, 1, Wx::ALIGN_CENTER_VERTICAL, 5);
>
>
>
> sizer.add_item(box, 0, Wx::ALIGN_CENTER|Wx::ALL, 5);
>
> end
>
> end
>
>
>
> How to make my title centered in the panel?
>
>
>
> Alejandro Michelin Salomon
>
>
>
> _____
>
> avast! Antivirus <http://www.avast.com> : Outbound message clean.
>
>
> Virus Database (VPS): 090319-0, 19/03/2009
> Tested on: 19/03/2009 17:32:59
> avast! - copyright (c) 1988-2009 ALWIL Software.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
wxruby-users mailing list
wxruby-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/wxruby-users
_____
avast! Antivirus <http://www.avast.com> : Inbound message clean.
Virus Database (VPS): 090319-0, 19/03/2009
Tested on: 20/03/2009 07:35:25
avast! - copyright (c) 1988-2009 ALWIL Software.
_____
avast! Antivirus <http://www.avast.com> : Outbound message clean.
Virus Database (VPS): 090319-0, 19/03/2009
Tested on: 20/03/2009 09:05:48
avast! - copyright (c) 1988-2009 ALWIL Software.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20090320/21b2d3a5/attachment-0001.html>
More information about the wxruby-users
mailing list