[wxruby-users] Xrc Q ; using mulitple layouts(Frames , dialogs , panels)

Jn Jn lists at ruby-forum.com
Wed Nov 19 15:32:14 EST 2008


Hi ,
  I am developing a simple GUI with wxruby. I am using wxFormbuilder to
get the xrc file.
  I need a simple Frame with menu item file and submenu open,save and
exit. And when I click on open(submenu) it should launch an
panel(dialog) which has filepicker.

 I believe I would be able to develop a dailog also under the same
project in wxFormbuilder(which it allowed without any warnings or
errors) ,when I run xrcise I get 2 classes under same xrc file. but when
try to load it when I click on open the applicaiton crashes.

 Can someone point to any sample program which uses multiple layouts
with xrc. What is the sequence of loading the objects .
Thanks
Jn

========================================================================


# 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: TestXrc.xrc
# Generated at: Wed Nov 19 12:00:04 -0800 2008

class TextXrc < Wx::Frame

  attr_reader :m_menubar2, :m_menu4, :m_menuitem5, :m_menuitem6,
              :m_menu5

  def initialize(parent = nil)
    super()
    xml = Wx::XmlResource.get
    xml.flags = 2 # Wx::XRC_NO_SUBCLASSING
    xml.init_all_handlers
    xml.load("TestXrc.xrc")
    xml.load_frame_subclass(self, parent, "MyFrame2")

    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_menubar2 = finder.call("m_menubar2")
    @m_menu4 = finder.call("m_menu4")
    @m_menuitem5 = finder.call("m_menuItem5")
    @m_menuitem6 = finder.call("m_menuItem6")
    @m_menu5 = finder.call("m_menu5")
    if self.class.method_defined? "on_init"
      self.on_init()
    end
  end
end



# 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: TestXrc.xrc
# Generated at: Wed Nov 19 12:00:04 -0800 2008

class BrowseFile < Wx::Dialog

  attr_reader :m_filepicker2

  def initialize(parent = nil)
    super()
    xml = Wx::XmlResource.get
    xml.flags = 2 # Wx::XRC_NO_SUBCLASSING
    xml.init_all_handlers
    xml.load("TestXrc.xrc")
    xml.load_dialog_subclass(self, parent, "MyDialog2")

    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_filepicker2 = finder.call("m_filePicker2")
    if self.class.method_defined? "on_init"
      self.on_init()
    end
  end
end
======================================================================
-- 
Posted via http://www.ruby-forum.com/.


More information about the wxruby-users mailing list