A very simple wxRuby loading a xrc file

Greetings,
I am trying to get a very simple .xrc file to load with no
interaction. This does run, but it will not exit cleanly. Can someone
please help me? I have been making progress, but I just cannot seem to
get that last bit. I am very new to wxruby.

Thanks,
Zignus

samples.xrc

<?xml version="1.0" encoding="ISO-8859-1"?> wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU 400,300 Sample 1 wxHORIZONTAL wxALIGN_CENTER_VERTICAL|wxALL 5 wxVERTICAL wxALIGN_CENTER_HORIZONTAL|wxALL 5 Ok wxALIGN_CENTER_HORIZONTAL|wxALL 5 Cancel wxALIGN_CENTER_HORIZONTAL|wxALL 5 Message... wxALIGN_CENTER_HORIZONTAL|wxALL 5 zignus was here

zignus.sample.rbw

require ‘wxruby’

Application class.

class XrcApp < Wx::App

def on_init
Wx::init_all_image_handlers() # Initializes handlers for all
supported controls/windows. In wxRuby versions 1.9.6 and later, this is
called automatically for you, so there is no need to call this method
xml = Wx::XmlResource.get() #Loads resources from the XML file
file. If this file does not exist, or contains invalid XML, an exception
will be raised; if successful, the loaded file name will be returneed.
xml.init_all_handlers() #Initializes handlers for all supported
controls/windows. In wxRuby versions 1.9.6 and later, this is called
automatically for you, so there is no need to call this method
xml.load(“samples.xrc”) #Loads resources from the XML file file.
If this file does not exist, or contains invalid XML, an exception will
be raised; if successful, the loaded file name will be returneed.
#
# Show the main frame.
#
frame = Wx::Frame.new(nil, -1, “Sample” ) #create the window
frame.set_client_size(Wx::Size.new(200,200)) #sets the size of
the window
#sizer = Wx::BoxSizer.new(Wx::VERTICAL)
xml.load_dialog_subclass(frame, nil, ‘SAMPLE_DIALOG’) #loads in
the .xrc into the window! Yea!!
#frame.set_sizer(sizer)
frame.show()
end

end

=begin
=end

XrcApp.new().main_loop() #Create a new object with no name from
‘XrcApp’ class and places in a loop.

I figured some things out.
You should use at the top of your Ruby code:
require ‘wxruby’
include Wx

Here is my code that works:

require ‘wxruby’
include Wx

Application class.

class XrcApp < Wx::App

def on_init
Wx::init_all_image_handlers()
xml = Wx::XmlResource.get()
xml.init_all_handlers()
xml.load(“SimplePanel.xrc”)
#
# Show the main frame.
#
frame = Wx::Frame.new( nil, -1, ‘Simple’ )
frame.set_client_size( Wx::Size.new( 200, 200))
xml.load_panel( frame, ‘ID_WXPANEL’)
frame.show()
end

end

XrcApp.new().main_loop()

and I created new .xrc file to go with it.
SimplePanel.xrc

<?xml version="1.0" encoding="UTF-8"?> wxTAB_TRAVERSAL Simple 1 wxVERTICAL wxALIGN_CENTER_HORIZONTAL|wxALL 5 Static text wxALIGN_CENTER_HORIZONTAL|wxALL 5 Static text wxALIGN_CENTER_HORIZONTAL|wxALL 5 Static text wxALIGN_CENTER_HORIZONTAL|wxALL 5 Static text

There it is.

Thanks,
Zignus

Zignus Arcanniss wrote:

I figured some things out.
You should use at the top of your Ruby code:
require ‘wxruby’
What version of wxRuby are you using? require ‘wxruby’ was used for the
very old version 0.6.0. I strongly recommend that you use version 2.0.0.
The old version is very buggy, has lots of missing features etc.

a