# Xrc xrcsie new user question

**URL:** <https://www.ruby-forum.com/t/xrc-xrcsie-new-user-question/141444>\
**Category:** wxRuby\
**Created:** [June 25, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/xrc-xrcsie-new-user-question/141444 "2008-06-25T22:39:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joseph\_edelstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@joseph\_edelstein](https://www.ruby-forum.com/u/joseph_edelstein)\
**Post date:** [June 25, 2008, 10:39pm UTC](https://www.ruby-forum.com/t/xrc-xrcsie-new-user-question/141444/1 "2008-06-25T22:39:40Z")

</div>

I am doing something wrong or missing a step. I am trying to get a  
panel that I made in DialogBlocks to come up in wxRuby. I made the XRC  
and ran xrcise on it. I am getting an error when trying to start it.

Ruby code:  
begin  
require ‘rubygems’  
rescue LoadError  
end

require ‘wx’  
include Wx  
require ‘bogus\_panel.rb’

class BogusPanel \< Bogus\_panel  
def initialize(parent)  
super(parent)  
end#def initialize  
end

class BogusFrame \< Wx::Frame  
def initialize  
super  
BogusPanel.new(self).set\_focus  
end#def initialize  
end#end Class

class BogusApp \< App  
def on\_init()  
BogusFrame.new.show  
end  
end

BogusApp.new.main\_loop()

xrcsie generated code:

# 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: bogus\_panel.xrc

# Generated at: Tue Jun 24 09:27:40 -0700 2008

begin  
require ‘rubygems’  
rescue LoadError  
end

require ‘wx’  
include Wx

class Bogus\_panel \< Wx::Panel

attr\_reader :num\_of\_fields\_textbox, :ddid\_textbox, :company\_textbox,  
:first\_name\_textbox, :last\_name\_textbox, :add1\_textbox,  
:add2\_textbox, :city\_textbox, :state\_textbox,  
:zip\_textbox, :country\_textbox, :email\_textbox,  
:phone\_textbox, :fax\_textbox, :title\_textbox,  
:source\_textbox, :source\_button, :result\_textbox,  
:result\_button, :gauge\_box, :preview\_button,  
:start\_button

def initialize(parent = nil)  
super()  
xml = Wx::XmlResource.get  
xml.flags = 2 # Wx::XRC\_NO\_SUBCLASSING  
xml.init\_all\_handlers  
xml.load(“bogus\_panel.xrc”)  
xml.load\_panel\_subclass(self, parent, “Bogus\_panel”)

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

@num_of_fields_textbox = finder.call("num_of_fields_textbox")
@ddid_textbox = finder.call("ddid_textbox")
@company_textbox = finder.call("company_textbox")
@first_name_textbox = finder.call("first_name_textbox")
@last_name_textbox = finder.call("last_name_textbox")
@add1_textbox = finder.call("add1_textbox")
@add2_textbox = finder.call("add2_textbox")
@city_textbox = finder.call("city_textbox")
@state_textbox = finder.call("state_textbox")
@zip_textbox = finder.call("zip_textbox")
@country_textbox = finder.call("country_textbox")
@email_textbox = finder.call("email_textbox")
@phone_textbox = finder.call("phone_textbox")
@fax_textbox = finder.call("fax_textbox")
@title_textbox = finder.call("title_textbox")
@source_textbox = finder.call("source_textbox")
@source_button = finder.call("source_button")
@result_textbox = finder.call("Result_textbox")
@result_button = finder.call("result_button")
@gauge_box = finder.call("gauge_box")
@preview_button = finder.call("preview_BUTTON")
@start_button = finder.call("start_button")
if self.class.method_defined? "on_init"
  self.on_init()
end

```

end  
end

---

<div class="post-metadata">

**Author:** ![joseph\_edelstein](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@joseph\_edelstein](https://www.ruby-forum.com/u/joseph_edelstein)\
**Post date:** [June 26, 2008, 7:29pm UTC](https://www.ruby-forum.com/t/xrc-xrcsie-new-user-question/141444/2 "2008-06-26T19:29:08Z")

</div>

Hi Joseph

Joseph E. wrote:

> I am doing something wrong or missing a step. I am trying to get a  
> panel that I made in DialogBlocks to come up in wxRuby. I made the XRC  
> and ran xrcise on it. I am getting an error when trying to start it.

Thanks for the report. You turned up a problem in wxRuby which means  
that the current version isn’t able to load a Wx::Panel subclass from  
XRC.

I have fixed this in our source repository, but for now you could get  
round this by starting from a top-level window type of “Frame” in your  
GUI editor, instead of Panel. In DialogBlocks, it should be  
straightforward to drag and drop your Panel layout into a new “Frame”  
class.

You also missed a step, which is that you must set the “name” of the XRC  
class you’re loading to be Bogus\_panel, instead of the default  
ID\_PANEL1, as in the attachment you posted.

Thanks again  
alex
