# Error: ...uninitialized constant Wxruby2

**URL:** <https://www.ruby-forum.com/t/error-uninitialized-constant-wxruby2/150148>\
**Category:** Ruby\
**Created:** [October 4, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-wxruby2/150148 "2008-10-04T18:42:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![learner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b782af/32.png) [@learner](https://www.ruby-forum.com/u/learner)\
**Post date:** [October 4, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-wxruby2/150148/1 "2008-10-04T18:42:37Z")

</div>

I have already installed the wx package with ruby gem:

gem install wxruby and now I am trying to run a gui sample program. As  
follow:

require ‘wx’  
include Wx  
class MyFrame \< Frame  
def initialize()  
super(nil, -1, ‘My Frame Title’)  
@my\_panel = Panel.new(self)  
@my\_label = StaticText.new(@my\_panel, -1, ‘My Label Text’,  
DEFAULT\_POSITION, DEFAULT\_SIZE, ALIGN\_CENTER)  
@my\_textbox = TextCtrl.new(@my\_panel, -1, ‘Default Textbox Value’)  
@my\_combo = ComboBox.new(@my\_panel, -1, ‘Default Combo Text’,  
DEFAULT\_POSITION, DEFAULT\_SIZE, [‘Item 1’, ‘Item 2’, ‘Item 3’])  
@my\_button = Button.new(@my\_panel, -1, ‘My Button Text’)  
end  
end

But anytime i try to run the code, I get following error message:

/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.8-x86-mingw32/lib/wx.rb:50:  
uninitialized constant Wxruby2::THE\_APP (NameError)

Does anybody knows how to solve this problem?

Thanks. Bou

---

<div class="post-metadata">

**Author:** ![learner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b782af/32.png) [@learner](https://www.ruby-forum.com/u/learner)\
**Post date:** [October 4, 2008, 6:55pm UTC](https://www.ruby-forum.com/t/error-uninitialized-constant-wxruby2/150148/2 "2008-10-04T18:55:28Z")

</div>

Bou DramÃ© wrote:

> ```
> @my_panel = Panel.new(self)
> @my_label = StaticText.new(@my_panel, -1, 'My Label Text',
> 
> ```
> 
> DEFAULT\_POSITION, DEFAULT\_SIZE, ALIGN\_CENTER)  
> @my\_textbox = TextCtrl.new(@my\_panel, -1, ‘Default Textbox Value’)  
> @my\_combo = ComboBox.new(@my\_panel, -1, ‘Default Combo Text’,  
> DEFAULT\_POSITION, DEFAULT\_SIZE, [‘Item 1’, ‘Item 2’, ‘Item 3’])  
> @my\_button = Button.new(@my\_panel, -1, ‘My Button Text’)  
> end  
> end

You need to add some code at the end of your sample to actually show one  
of these frames. Something like

App.run do  
frame = MyFrame.new  
frame.show  
end

That should do the trick. You can get more help on the wxruby-users  
mailing list: [http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists](http://wxruby.rubyforge.org/wiki/wiki.pl?MailingLists)

The error message you’re getting at the moment is a minor bug in 1.9.8,  
it’s already fixed in Subversion for the upcoming 2.0 release.

alex
