RadioBox--majorDimension backwards


#1

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


#2

7stud – wrote:

    Wx::RA_SPECIFY_COLS    #previous number applies to columns
    :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

After your kind words about the docs, it’s a documentation bug. The
“majorDimension” argument should be specified with “:major_dimension” -
train_case not CamelCase. I think it works as expected if the parameter
name is given correctly.

Fixed in the documentation with SVN:2062

thanks for the report and sample
alex


#3

Submitted as bug #24992 here:

http://rubyforge.org/tracker/index.php?group_id=35&atid=218

If you run the following program, it will show two RadioBoxes side by
side. One RadioBox will be laid out in one column, with one radio
button per line. The other RadioBox will be laid out in one row, with
all the radio buttons on one line. However, the only difference between
the code for the two RadioBox’s is that one uses positional args and the
other uses keyword args.

require “rubygems”
require “wx”

class MyFramePosArgs < 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
    -1,                    #-1 => wxruby picks id
    "Drinks",              #label for box surrounding radios
    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    #preceding number applies to columns
)

show     #equivalent to self.show, makes the frame visible

end
end

class MyFrameKeyWordArgs < 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(500, 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 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
)

show     #equivalent to self.show, makes the frame visible

end
end

class MyApp < Wx::App
def on_init
MyFramePosArgs.new
MyFrameKeyWordArgs.new
end
end

MyApp.new.main_loop


#4

Alex F. wrote:

After your kind words about the docs, it’s a documentation bug. The
“majorDimension” argument should be specified with “:major_dimension” -
train_case not CamelCase. I think it works as expected if the parameter
name is given correctly.

Yep, that works for me. Thanks for the response.