# wxRuby menu item checkbox

**URL:** <https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909>\
**Category:** wxRuby\
**Created:** [March 29, 2010, 5:26am UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909 "2010-03-29T05:26:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 29, 2010, 5:26am UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/1 "2010-03-29T05:26:20Z")

</div>

I am using wxFormBuilder version 3.0.57 to produce an xrc file for my  
wxRuby GUI.  
I have used this successfully for some time now.  
However, I have been unable to get a checkbox menu item to function the  
way that I expect it to. That is, when I try to test if the box is  
checked, as described in the wxRuby doc’s, it generates an error stating  
that .is\_checked is not a method.

I am doing all of this exactly the same way as I work with non-menu  
checkboxes.

What is the problem here?

Sample code:

puts @my\_menuitem\_checkbox.is\_checked

Error message:

undefined method `is\_checked’ for 120:Fixnum (NoMethodError)

Note: the 120 in the error message is the ID for @my\_menuitem\_checkbox.

Platform: Ubuntu 9.04 (32bit), Ruby 1.8.7, everything is up to date.

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 29, 2010, 10:47am UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/2 "2010-03-29T10:47:55Z")

</div>

My code runs just ok  
for test, I make my form like this  
I don’t know how you make yours  
but I hope this help

require ‘rubygems’  
require ‘wx’  
class Coba\_b \< Wx::Frame

```
def initialize(parent=nil)
    super parent, -1, "Coba", DEFAULT_POSITION, Size.new(600,400),

```

DEFAULT\_FRAME\_STYLE

```
    @menu_bar_101 = MenuBar.new(0)
    @menu_coba = Menu.new("&Coba", 0)
    @menu_check = MenuItem.new(@menu_coba, 103, "coba check", "",

```

ITEM\_CHECK)  
@menu\_coba.append\_item(@menu\_check)  
evt\_menu(103) { |event| menu\_check\_call(event) }  
@menu\_bar\_101.append(@menu\_coba, “&Coba”)  
self.set\_menu\_bar @menu\_bar\_101  
@panel\_104 = Panel.new(self, -1)  
@btn\_is\_checked = Button.new(@panel\_104, -1, “checked”,  
DEFAULT\_POSITION, DEFAULT\_SIZE, 0, DEFAULT\_VALIDATOR )

```
    evt_button(@btn_is_checked) { |event| 

```

btn\_is\_checked\_click(event) }

```
    evt_close{ |event| on_close(event) }
    on_load()
end

def btn_is_checked_click(event)
    puts "checked" if @menu_check.is_checked
end

```

end

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 29, 2010, 5:50pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/3 "2010-03-29T17:50:35Z")

</div>

Hi list!  
I worked with wxWidgets in C++, and now I’d like to play with wxruby.  
But, with a minimal app like this…

#!/usr/bin/ruby  
require “rubygems”  
require “wx”  
include Wx  
class Minima \< App  
def on\_init  
Frame.new(nil, -1, “Applicazione minima”).show()  
end  
end  
Minima.new.main\_loop

… I get “Segmentation fault”:  
/usr/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-linux/lib/wx/keyword\_ctors.rb:168:  
[BUG] Segmentation fault  
ruby 1.8.5 (2006-08-25) [i386-linux]

Running it with gdb:  
Program received signal SIGSEGV, Segmentation fault.  
0x002e11e8 in wcslen () from /lib/libc.so.6

My sistem is:  
Linux CentOS 5.4 updated  
Ruby 1.8.5  
wxGTK, wxBase and wxGTK-gl installed from distro (2.8.9-2.el5)

Thanks for help!

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 29, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/4 "2010-03-29T23:59:54Z")

</div>

Is this a Gem install of wxRuby on your OS, or are you compiling from  
source?

On Mon, Mar 29, 2010 at 6:31 AM, Pierpaolo Giordani \<

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 30, 2010, 12:01am UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/5 "2010-03-30T00:01:04Z")

</div>

Actually,

Never mind, just re-read the error message, and your specs.

Three things of note here. First, the Gem that you have installed is  
built  
on Ubuntu, and may have problems on Red Hat Linux and Derivatives.  
Second,  
wxRuby is built against Ruby 1.8.7, and there may  
be incompatibilities between 1.8.5 in the C back-end, compared to 1.8.7.  
And the final note here, is that it seems you are familiar with the  
whole  
compiling process with C++, and wxWidgets. Take a look at our wiki,  
specifically under “How to build wxRuby”, for instructions on how to  
build  
wxWidgets, and wxRuby.

My best suggestion for this kind of situation, is that if CentOS’ repos  
do  
not have the latest version of Ruby available, then I would compile Ruby  
1.8.7 from source, and install that. Then ensure that wxWidgets is at  
least  
2.8.10. If it isn’t, then grab wxWidgets, and compile that from source,  
following the instructions on our Wiki, then finally build wxRuby.

hth,

Mario

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 30, 2010, 4:46pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/6 "2010-03-30T16:46:55Z")

</div>

I don’t have libwx\_gtk2u\_stc-2.8.so.0! Instead I  
have /usr/local/lib/libwx\_gtk2u\_stc-2.8.a

Pierpaolo Giordani

Il giorno mar, 30/03/2010 alle 16.00 +0200, Pierpaolo Giordani ha  
scritto:

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 30, 2010, 8:22pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/7 "2010-03-30T20:22:22Z")

</div>

Make sure that you go into your contrib folder, as described in the  
Wiki, to  
compile STC into a Shared Library. Make sure to run make, and make  
install,  
that will install the libwx\_gtk2u\_stc.so library. The .a library is  
just  
the assembly for the compiled code, to be statically linked into any  
executable, or library that is compiled against it.

On Tue, Mar 30, 2010 at 10:24 AM, Pierpaolo Giordani \<

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 30, 2010, 4:00pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/8 "2010-03-30T16:00:45Z")

</div>

I don’t really need wxruby on CentOS, because the final destination is  
fedora 12 x86\_64.  
So I compiled wxWidgets with the suggested options (and the patch for  
recent GTK+ versions) on fedora. All ok.  
Then I downgraded swig to 1.3.34 and compiled wxruby and the contrib  
add. All seems ok - no errors.  
Rebuild of ruby is very hard (you need a patch for openssl 1.0, but I  
found half a dozen of patches and I don’t know the rigth one) - I’ll try  
the pre-build ruby 1.8.6 (2009-08-04 patchlevel 383), for now.  
When I launch my miniml app this is the output:

/usr/lib64/ruby/site\_ruby/1.8/x86\_64-linux/wxruby2.so:  
libwx\_gtk2u\_stc-2.8.so.0: cannot open shared object file: No such file  
or directory - /usr/lib64/ruby/site\_ruby/1.8/x86\_64-linux/wxruby2.so  
(LoadError)  
from /usr/lib/ruby/site\_ruby/1.8/wx.rb:12  
from ./minima.rb:3:in `require’  
from ./minima.rb:3

but there is a /usr/lib64/ruby/site\_ruby/1.8/x86\_64-linux/wxruby2.so  
file! (55M , read and execute permissions for all).  
I’m confused.

Pierpaolo Giordani

Il giorno lun, 29/03/2010 alle 17.55 -0400, Mario S. ha scritto:

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 31, 2010, 11:40am UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/9 "2010-03-31T11:40:29Z")

</div>

Solved!  
Just for fedora 12-64bit users, this is the roadmap:  
yum erase wxGTK wxBase  
yum install gstreamer-devel gstreamer-plugins-base-devel  
ruby-gstreamer-devel ruby-gconf2-devel mesa-libGL-devel  
mesa-libGLU-devel ruby-gconf2-devel  
(not sure if they are all useful)  
Download wxWidgets, extract in a folder, and copy the patch for GTK+  
Create a build-wxruby folder inside the wxWidgets folder  
In build-wxruby, give this command: …/configure --disable-shared  
–with-gtk --enable-monolithic --enable-unicode --disable-debug  
–enable-catch\_segvs --enable-graphics\_ctx --enable-mediactrl  
–with-opengl --with-libjpeg=builtin --with-libpng=builtin  
–with-libtiff=builtin --with-zlib=builtin --with-expat=builtin  
–enable-gui --enable-xrc --enable-mdi --enable-gif --enable-pcx  
–enable-iff --enable-pnm --enable-xpm CFLAGS=-fPIC CXXFLAGS=-fPIC  
LDFLAGS=-fPIC  
then make and make install (be root)  
move to …contrib/src/stc, then make and make install  
yum erase swig  
Download and install swig 1.3.34  
Download wxruby, then rake and rake install

thanks Mario!

Il giorno mar, 30/03/2010 alle 13.54 -0400, Mario S. ha scritto:

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 31, 2010, 3:17pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/10 "2010-03-31T15:17:05Z")

</div>

Your welcome.

On Wed, Mar 31, 2010 at 5:35 AM, Pierpaolo Giordani \<

---

<div class="post-metadata">

**Author:** ![vanik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac8455/32.png) [@vanik](https://www.ruby-forum.com/u/vanik)\
**Post date:** [March 30, 2010, 11:11pm UTC](https://www.ruby-forum.com/t/wxruby-menu-item-checkbox/185909/11 "2010-03-30T23:11:40Z")

</div>

Dear Pierpaolo Giordani and Mario S.:

I posted this topic: “wxRuby menu item checkbox” because I needed help  
with a specific wxRuby - wxFormBuilder problem.

The Segmentation fault issue posted by Pierpaolo Giordani (pierp) on  
29.03.2010 17:50 should never have been placed inside the “wxRuby menu  
item checkbox” topic, since it is not related. But the two of you have  
continued to use the “wxRuby menu item checkbox” topic for addressing an  
unrelated topic, which has resulted in my not getting any suitable  
answers to the topic that I posted. I would appreciate your moving your  
issue to its own topic.

Thanks,

Gary
