I built a small form in wxFormBuilder. In cmd i wrote xrcise -o test.rb ui.xrc output was C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/lib/wx_sugar/xrc/outputter.rb:4 6:in `clean_id_attr_readers'': undefined method `each'' for #<String:0xba5850> (No MethodError) from (erb):16:in `output'' from C:/ruby/lib/ruby/1.9.1/erb.rb:753:in `eval'' from C:/ruby/lib/ruby/1.9.1/erb.rb:753:in `result'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/lib/wx_sugar/xrc/o utputter.rb:19:in `output'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/bin/xrcise:126:in `block (2 levels) in <top (required)>'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/bin/xrcise:125:in `each'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/bin/xrcise:125:in `block in <top (required)>'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/bin/xrcise:124:in `open'' from C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/bin/xrcise:124:in `<top (required)>'' from C:/ruby/bin/xrcise:19:in `load'' from C:/ruby/bin/xrcise:19:in `<main>'' File : ui.xrc <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1"> <object class="wxFrame" name="frmMain" subclass="XrcFrameMain"> <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style> <size>500,300</size> <title>Test</title> <object class="wxGridSizer"> <rows>2</rows> <cols>2</cols> <vgap>0</vgap> <hgap>0</hgap> <object class="sizeritem"> <option>1</option> <flag>wxEXPAND | wxALL</flag> <border>5</border> <object class="wxPanel" name="m_panel1"> <style>wxTAB_TRAVERSAL</style> <object class="wxBoxSizer"> <orient>wxVERTICAL</orient> <object class="sizeritem"> <option>0</option> <flag>wxALL</flag> <border>5</border> <object class="wxTextCtrl" name="m_textCtrl1"> <value></value> <maxlength>0</maxlength> </object> </object> <object class="sizeritem"> <option>0</option> <flag>wxALL</flag> <border>5</border> <object class="wxTextCtrl" name="m_textCtrl2"> <value></value> <maxlength>0</maxlength> </object> </object> <object class="sizeritem"> <option>0</option> <flag>wxALL</flag> <border>5</border> <object class="wxButton" name="m_button8"> <label>MyButton</label> <default>0</default> </object> </object> <object class="sizeritem"> <option>0</option> <flag>wxALL</flag> <border>5</border> <object class="wxButton" name="m_button7"> <label>MyButton</label> <default>0</default> </object> </object> </object> </object> </object> <object class="sizeritem"> <option>1</option> <flag>wxEXPAND | wxALL</flag> <border>5</border> <object class="wxPanel" name="m_panel2"> <style>wxTAB_TRAVERSAL</style> <object class="wxGridSizer"> <rows>2</rows> <cols>2</cols> <vgap>0</vgap> <hgap>0</hgap> <object class="sizeritem"> <option>0</option> <flag>wxALL</flag> <border>5</border> <object class="wxCalendarCtrl" name="m_calendar1"> <style>wxCAL_SHOW_HOLIDAYS</style> </object> </object> </object> </object> </object> </object> <object class="wxMenuBar" name="m_menubar1"> <label>MyMenuBar</label> <object class="wxMenu" name="m_menu1"> <label>File</label> </object> <object class="wxMenu" name="m_menu11"> <label>Help</label> </object> </object> </object> </resource> Can someone explain what''s wrong? -- Posted via http://www.ruby-forum.com/.
Chris Stuff wrote:> I built a small form in wxFormBuilder. In cmd i wrote > > xrcise -o test.rb ui.xrc > > output was > > C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/lib/wx_sugar/xrc/outputter.rb:4 > 6:in `clean_id_attr_readers'': undefined method `each'' for > #<String:0xba5850> (No > MethodError)Thanks for the report. I thought I''d fixed xrcise to work with ruby 1.9, but it seems not. I''ll look to update wx_sugar for 1.9 shortly. In the meantime, as hendra says, you can just use ruby 1.8 to run xrcise. The code generated is no different for Ruby 1.8 and Ruby 1.9. alex
Chris Stuff wrote:> I built a small form in wxFormBuilder. In cmd i wrote > > xrcise -o test.rb ui.xrc > > output was > > C:/ruby/lib/ruby/gems/1.9.1/gems/wx_sugar-0.1.22/lib/wx_sugar/xrc/outputter.rb:4....> > Can someone explain what''s wrong?When I borrowed your xrc file here''s what I got using linux: File:test.rb # This class was automatically generated from XRC source. It is not # recommended that this file is edited directly; instead, inherit from # this class and extend its behaviour there. # # Source file: UI.xrc # Generated at: Mon Aug 24 17:30:14 -0600 2009 class XrcFrameMain < Wx::Frame attr_reader :m_panel1, :m_textctrl1, :m_textctrl2, :m_button8, :m_button7, :m_panel2, :m_calendar1, :m_menubar1, :m_menu1, :m_menu11 def initialize(parent = nil) super() xml = Wx::XmlResource.get xml.flags = 2 # Wx::XRC_NO_SUBCLASSING xml.init_all_handlers xml.load("UI.xrc") xml.load_frame_subclass(self, parent, "frmMain") finder = lambda do | x | int_id = Wx::xrcid(x) begin Wx::Window.find_window_by_id(int_id, self) || int_id # Temporary hack to work around regression in 1.9.2; remove # begin/rescue clause in later versions rescue RuntimeError int_id end end @m_panel1 = finder.call("m_panel1") @m_textctrl1 = finder.call("m_textCtrl1") @m_textctrl2 = finder.call("m_textCtrl2") @m_button8 = finder.call("m_button8") @m_button7 = finder.call("m_button7") @m_panel2 = finder.call("m_panel2") @m_calendar1 = finder.call("m_calendar1") @m_menubar1 = finder.call("m_menubar1") @m_menu1 = finder.call("m_menu1") @m_menu11 = finder.call("m_menu11") if self.class.method_defined? "on_init" self.on_init() end end end File: test2.rb begin require ''rubygems'' rescue LoadError end require ''wx'' require ''test.rb'' # Inherit from the generated base class and set up event handlers class AppFrame < XrcFrameMain def initialize super() end end # Wx::App is the container class for any wxruby app. To start an # application, either define a subclass of Wx::App, create an instance, # and call its main_loop method, OR, simply call the Wx::App.run class # method, as shown here. Wx::App.run do AppFrame.new.show end The second file I created manually and it works. At least it''s a start. Philip -- Posted via http://www.ruby-forum.com/.