# RadioBox--majorDimension backwards

**URL:** <https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142>\
**Category:** wxRuby\
**Created:** [March 28, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142 "2009-03-28T17:21:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![7stud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/7/57b2e6/32.png) [@7stud](https://www.ruby-forum.com/u/7stud)\
**Post date:** [March 28, 2009, 5:21pm UTC](https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142/1 "2009-03-28T17:21:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![7stud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/7/57b2e6/32.png) [@7stud](https://www.ruby-forum.com/u/7stud)\
**Post date:** [March 30, 2009, 9:51pm UTC](https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142/2 "2009-03-30T21:51:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![7stud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/7/57b2e6/32.png) [@7stud](https://www.ruby-forum.com/u/7stud)\
**Post date:** [March 29, 2009, 3:38pm UTC](https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142/3 "2009-03-29T15:38:06Z")

</div>

Submitted as bug #24992 here:

[http://rubyforge.org/tracker/index.php?group\_id=35&atid=218](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

---

<div class="post-metadata">

**Author:** ![7stud](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/7/57b2e6/32.png) [@7stud](https://www.ruby-forum.com/u/7stud)\
**Post date:** [March 31, 2009, 6:28am UTC](https://www.ruby-forum.com/t/radiobox-majordimension-backwards/164142/4 "2009-03-31T06:28:14Z")

</div>

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.
