Forum: wxRuby Titled border

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Pierre P. (Guest)
on 2009-04-10 06:09
Hi folks,

I have a few ListBox controls in my small app, and I wanted to put a
kind of title above each of them.
The easiest and somehow best looking solution I had thought of, was a
kind of border around the ListBox which would have some text at it's
top. ( for instance like:
http://www.cloudgarden1.com/swing_tutorial/titled_border.png the left
circle ).

Is there anything like that in the API? I had a look but couldn't find
anything...

Regards,
Pierre
Alex F. (Guest)
on 2009-04-10 16:38
(Received via mailing list)
Hi Pierre

Pierre P. wrote:
>
The control you want is Wx::StaticBox (and also see Wx::StaticBoxSizer)

http://wxruby.rubyforge.org/doc/staticbox.html

a
Pierre P. (Guest)
on 2009-04-14 09:58
Alex F. wrote:
> Hi Pierre
>
> Pierre P. wrote:
>>
> The control you want is Wx::StaticBox (and also see Wx::StaticBoxSizer)
>
> http://wxruby.rubyforge.org/doc/staticbox.html
>
> a

Thanks Alex, that was indeed the control I was looking for!
Yet, somehow, I quite didn't get how to use it.
For instance if if I want to add an other control in it (ListBox,
StaticText, whatever), it'll also be in the top-left corner on the top
of the border, instead of in it's center.
I guess I'm missing something really basic, I just couldn't figure out
yet what.
Alex F. (Guest)
on 2009-04-14 15:31
(Received via mailing list)
Pierre P. wrote:
> Thanks Alex, that was indeed the control I was looking for!
> Yet, somehow, I quite didn't get how to use it.
> For instance if if I want to add an other control in it (ListBox,
> StaticText, whatever), it'll also be in the top-left corner on the top
> of the border, instead of in it's center.

With Sizer-based layouts (recommended) I've found it easier to use
Wx::StaticBoxSizer to get a label round controls. I probably should have
pointed you at this first. See the simple example below:

alex
__

require 'wx'

Wx::App.run do
  frame = Wx::Frame.new(nil, :title => 'staticbox demo')
  panel = Wx::Panel.new(frame)
  sizer = Wx::StaticBoxSizer.new( Wx::VERTICAL, panel, 'a label')
  sizer.add( Wx::ListBox.new(panel), 1, Wx::ALL|Wx::GROW, 5 )
  panel.sizer = sizer
  frame.show
end
Pierre P. (Guest)
on 2009-04-15 04:46
Awesome Alex!
Thank to you it looks like I'll have a great and productive day today
:-)

Big thanks
This topic is locked and can not be replied to.