wxRuby by wxSugar

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.

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

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?

Hello Michael,

On Tue, Oct 19, 2010 at 5:54 AM, Misha O. [email protected]
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 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

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

Why everybody silent?

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

Mario, here this files: 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.