# wxRuby by wxSugar

**URL:** <https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692>\
**Category:** wxRuby\
**Created:** [October 19, 2010, 1:43am UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692 "2010-10-19T01:43:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 19, 2010, 1:43am UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/1 "2010-10-19T01:43:24Z")

</div>

Hello.

I have a ruby 1.9 and create a file trap.xrc in DialogBlocks.

Later I create a trap.rb: xrcise -o trap.rb trap.xrc … All good.

But late I create a file ed.rb:

* * *

require ‘wx’  
require ‘trap’

class Exsys \< wxFrame  
def initialize  
super  
end  
end

Wx::App.run do  
Exsys.new.show  
end

* * *

It doesn’t work! Why?

Please open attached image ‘xx.jpg’, here wrote error.

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 19, 2010, 4:01am UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/2 "2010-10-19T04:01:33Z")

</div>

I believe your using Ruby 1.9.2, and if so, it no longer references the  
current directory, or rather the directory from where the script is  
launched  
from, as a path in which to look for files to require in. You can do  
one of  
two things, you can either do:

require ‘wx’  
require ‘./trap’

or you could do:

$:.unshift “.”  
requrie ‘wx’  
require ‘trap’

Either of these methods will work to get trap.rb to load up under 1.9.2.  
This isn’t so much a wxRuby Problem, as it is a design change by Ruby  
1.9  
core.

hth,

Mario

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 19, 2010, 11:54am UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/3 "2010-10-19T11:54:36Z")

</div>

Thanks, Mario! Now I have else three problems.

1. I create an XRC file with a label, combobox and button

---------- XRC

\<?xml version="1.0" encoding="UTF-8"?\> wxCAPTION|wxSYSTEM\_MENU|wxCLOSE\_BOX 640,480 FFF 1 wxVERTICAL wxALIGN\_CENTER\_HORIZONTAL|wxTOP 220 Check your location wxALIGN\_CENTER\_HORIZONTAL|wxALL 5 100,-1 wxCB\_DROPDOWN USA Canada wxALIGN\_CENTER\_HORIZONTAL|wxALL 5 # HERE Next 

----------- RB

# -_- coding: utf-8 -_-

require ‘wx’  
require ‘./trap’

class Exsys \< TFB  
def initialize  
super  
evt\_button (next\_btn) {next\_go} # HERE  
end  
end

def next\_go

# Many Testing Code

end

Wx::App.run do  
Exsys.new.show()  
end

* * *

I need to start an def next\_go, if I click button next\_btn (see HERE  
places in the code). It doesn’t work, see the attached image.

1. How I can read a value from ComboBox?

2. How I can disable and enable Sizer?

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 19, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/4 "2010-10-19T13:11:24Z")

</div>

Hello Michael,

On Tue, Oct 19, 2010 at 5:54 AM, Misha O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> <size>640,480</size>
> </object>
> </object>
> 
> ```
> 
> evt\_button (next\_btn) {next\_go} # HERE Exsys.new.show() end
> * * *
> 
> I need to start an def next\_go, if I click button next\_btn (see HERE  
> places in the code). It doesn’t work, see the attached image.

The next\_btn should actually be accessable through @next\_btn, since you  
are  
inheriting the TFB class in your Exsys class.

Try doing: evt\_button(@next\_btn) { next\_go }

> 1. How I can read a value from ComboBox?

See [http://wxruby.rubyforge.org/doc/combobox.html](http://wxruby.rubyforge.org/doc/combobox.html) Specifically  
#get\_value  
and #get\_current\_selection. Since ComboBox has a TextEntry and a Choice  
setup with it, you need to compare between the TextEntry and Choice to  
ensure you are getting the correct value out of it.

> 1. How I can disable and enable Sizer?

First you need to get the sizer, by using Window#get\_containing\_sizer,  
then  
you can use Window#hide, or Window#show to hide/show a Sizer, and  
Window#disable or Window#enable to disable/enable a set of controls.

There’s no physical way to disable a Sizer to prevent the sizer from  
resizing in the window. You can only either hide / show it, or  
enable/disable the controls within it.

> 

hth,

Mario

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 19, 2010, 6:41pm UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/5 "2010-10-19T18:41:16Z")

</div>

Mario, I do what you say. This is new error in 1): see attached please.

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 22, 2010, 10:49pm UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/6 "2010-10-22T22:49:07Z")

</div>

Why everybody silent?

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 23, 2010, 9:30am UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/7 "2010-10-23T09:30:57Z")

</div>

Sorry Michael,

I tend to not get much time to respond to emails, as I’m trying to run  
through everything. Could you send me attached a copy of your XRC, and  
Ruby  
Source files, so I can see where the problem may be in the code?

Thanks,

Mario

---

<div class="post-metadata">

**Author:** ![rarstd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/65b543/32.png) [@rarstd](https://www.ruby-forum.com/u/rarstd)\
**Post date:** [October 27, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/wxruby-by-wxsugar/197692/8 "2010-10-27T12:19:24Z")

</div>

Mario, here this files: [Free large file hosting. Send big files the easy way!](http://www.sendspace.com/file/q93zj9)

The first button, Ctrl-C, must copy text frim label to textctrl.

The second button must hide sizer which parent to textctrl on the first  
click, and in the second show it.

Thanks, Michael.
