Xrc xrcsie new user question

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

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