The layout of the RadioBox in this code works as the docs describe:
radios = Wx::RadioBox.new(
panel, #parent
-1, #-1 => wxruby picks id
"Drinks", #label for box surrounding radio buttons
Wx::Point.new(20, 5),
Wx::DEFAULT_SIZE,
drink_choices, #the labels for the radio buttons
1, #max number of columns
Wx::RA_SPECIFY_COLS #previous number applies to columns
)
When I run a program with that code in it, the RadioBox is a vertical
column with one radio button per line. But when I switch to keyword
arguments:
radios = Wx::RadioBox.new(
panel, #parent
:id => -1, #-1 => wxruby picks id
:label => "Drinks", #label for box surrounding radios
:pos => Wx::Point.new(20, 5),
:size => Wx::DEFAULT_SIZE,
:choices => drink_choices, #the labels for the radio buttons
:majorDimension => 1, #max number of columns
:style => Wx::RA_SPECIFY_COLS #number applies to columns
)
…the RadioBox lays out as one row with all the radio buttons on one
line. If I change
Wx::RA_SPECIFY_COLS
to
Wx::RA_SPECIFY_ROWS
then the RadioBox lays out like the first example–in one vertical
column with a radio button on each line. Is that a bug?
wxruby 2.0
ruby 1.8.6
mac osx 10.4.11
Here’s the full program:
require “rubygems”
require “wx”
class MyFrame < Wx::Frame
def initialize
super(nil, #parent
:id => -1, #-1 => wxruby picks id
:title => “RadioBox Example”, #displays on top of window
:pos => Wx::Point.new(150, 25), #or Wx::DEFAULT_POSITION
:size => Wx::Size.new(300, 200) #or Wx::DEFAULT_SIZE
)
panel = Wx::Panel.new(
self, #parent, self refers to this frame
:id => -1 #-1 => wxruby picks the id
)
drink_choices = ["coffee", "tea", "juice", "milk"]
radios = Wx::RadioBox.new(
panel, #parent
:id => -1, #-1 => wxruby picks id
:label => "Drinks", #label for box surrounding radio
buttons
:pos => Wx::Point.new(20, 5),
:size => Wx::DEFAULT_SIZE,
:choices => drink_choices, #the labels for the radio buttons
:majorDimension => 1, #max number of columns
:style => Wx::RA_SPECIFY_COLS #number applies to columns
)
show #equivalent to self.show, makes the frame visible
end
end
class MyApp < Wx::App
def on_init
MyFrame.new
end
end
MyApp.new.main_loop