Xrcise -o test.rb ui.xrc

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 methodeach’ for
#String:0xba5850 (No
MethodError)
from (erb):16:in output' from C:/ruby/lib/ruby/1.9.1/erb.rb:753:ineval’
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:inoutput’
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:ineach’
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:inopen’
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:inload’
from C:/ruby/bin/xrcise:19:in `’

File : ui.xrc

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL 500,300 Test 2 2 0 0 1 wxEXPAND | wxALL 5 wxTAB_TRAVERSAL wxVERTICAL 0 wxALL 5 0 0 wxALL 5 0 0 wxALL 5 MyButton 0 0 wxALL 5 MyButton 0 1 wxEXPAND | wxALL 5 wxTAB_TRAVERSAL 2 2 0 0 0 wxALL 5 wxCAL_SHOW_HOLIDAYS MyMenuBar File Help

Can someone explain what’s wrong?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs