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.
on 2010-10-19 01:43
on 2010-10-19 04:01
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
on 2010-10-19 11:54
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"?> <resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc"> <object class="wxFrame" name="ID_WXFRAME" subclass="TFB"> <style>wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX</style> <size>640,480</size> <title>FFF</title> <centered>1</centered> <object class="wxBoxSizer"> <orient>wxVERTICAL</orient> <object class="sizeritem"> <flag>wxALIGN_CENTER_HORIZONTAL|wxTOP</flag> <border>220</border> <object class="wxStaticText" name="wxID_STATIC"> <label>Check your location</label> </object> </object> <object class="sizeritem"> <flag>wxALIGN_CENTER_HORIZONTAL|wxALL</flag> <border>5</border> <object class="wxComboBox" name="where_are_you"> <size>100,-1</size> <style>wxCB_DROPDOWN</style> <content> <item>USA</item> <item>Canada</item> </content> </object> </object> <object class="sizeritem"> <flag>wxALIGN_CENTER_HORIZONTAL|wxALL</flag> <border>5</border> <object class="wxButton" name="next_btn"> # HERE <label>Next</label> </object> </object> </object> </object> </resource> ----------- 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. 2) How I can read a value from ComboBox? 3) How I can disable and enable Sizer?
on 2010-10-19 13:11
Hello Michael, On Tue, Oct 19, 2010 at 5:54 AM, Misha Ognev <lists@ruby-forum.com> wrote: > <size>640,480</size> > </object> > </object> > </resource> > 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 } > 2) 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. > 3) 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
on 2010-10-23 09:30
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
on 2010-10-27 12:19
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.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.


