[wxruby-users] xrcise question
Heinrich Piard
lists at ruby-forum.com
Sat Nov 15 16:11:55 EST 2008
Alex Fenton wrote:
> Heinrich Piard wrote:
>> one more question popped up:
>>
>> 14:37:40: Error: Cannot load resources from file
>> 'file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc'.
>> c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in
>> `load': Failed to load XRC from 'nonam.xrc'; check the file exists and
>> is valid XML (RuntimeError)
> The filename looks a bit suspicious to me. I would expect it to be a
> valid path rather than a mangled-looking URL. Hard to know where this
> came from without knowing more about your project layout.
>
> I would check that you call xrcise with a relative path, in a typical
> project structure. Eg I have
>
> app.rb
> lib/*.*/rb
> share/xrc.xrc
>
> I call "xrcise share/xrc.xrc" from the base directory and that means
> that the paths resolve fine.
>
> a
Hello,
here is my code. Is still can't get it to work.
# 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: wxFormBuilder\nonam.xrc
# Generated at: Fri Nov 14 17:16:34 -0500 2008
require 'wx'
include Wx
class CometApplication < Wx::Frame
attr_reader :m_statusbar1, :m_toolbar1, :m_textctrl1, :m_button2,
:m_button3
def initialize(parent = nil)
super()
xml = Wx::XmlResource.get
xml.flags = 2 # Wx::XRC_NO_SUBCLASSING
xml.init_all_handlers
xml.load("wxFormBuilder\nonam.xrc")
xml.load_frame_subclass(self, parent, "MyFrame1")
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_statusbar1 = finder.call("m_statusBar1")
@m_toolbar1 = finder.call("m_toolBar1")
@m_textctrl1 = finder.call("m_textCtrl1")
@m_button2 = finder.call("m_button2")
@m_button3 = finder.call("m_button3")
if self.class.method_defined? "on_init"
self.on_init()
end
end
end
class MyApp < App
def initialize()
CometApplication.new
end
end
MyApp.new.main_loop()
I start the code from C:\ruby\ruby_scripts\test.rb and the xrc file is
in C:\ruby\ruby_scripts\wxFormBuilder\nonam.xrc
--
Posted via http://www.ruby-forum.com/.
More information about the wxruby-users
mailing list