# Xrcise -o test.rb ui.xrc

**URL:** <https://www.ruby-forum.com/t/xrcise-o-test-rb-ui-xrc/173515>\
**Category:** wxRuby\
**Created:** [August 10, 2009, 9:16pm UTC](https://www.ruby-forum.com/t/xrcise-o-test-rb-ui-xrc/173515 "2009-08-10T21:16:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [August 10, 2009, 9:16pm UTC](https://www.ruby-forum.com/t/xrcise-o-test-rb-ui-xrc/173515/1 "2009-08-10T21:16:47Z")

</div>

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 `’

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?

---

<div class="post-metadata">

**Author:** ![yetanothergeek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/8e8cbc/32.png) [@yetanothergeek](https://www.ruby-forum.com/u/yetanothergeek)\
**Post date:** [August 25, 2009, 1:48am UTC](https://www.ruby-forum.com/t/xrcise-o-test-rb-ui-xrc/173515/2 "2009-08-25T01:48:11Z")

</div>

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
