[wxruby-users] xml.load_panel
Alex Fenton
alex at pressure.to
Mon Aug 25 09:46:34 EDT 2008
Hi
Max Salov wrote:
> Hello,
> I cannot correctly load panel from xrc-file. My test programm is below.
> Problem is that panel content is drawn not in place of 'DYMMYPANEL', but
> in upper-left corner. Please, help me to find mistake.
>
> #!/usr/bin/ruby -w
> require 'wx'
> $ui_dir = File.dirname(__FILE__)
> class MainFrame < Wx::Frame
> def initialize(parent = nil)
> super
> xrc_file = File.join $ui_dir,'test.xrc'
> xml = Wx::XmlResource.get
> xml.flags = Wx::XRC_NO_SUBCLASSING | Wx::XRC_NO_RELOADING
> xml.init_all_handlers
> xml.load xrc_file
> xml.load_frame_subclass(self,parent,'MAINFRAME')
> @finder = lambda do |x|
> id = Wx::xrcid(x)
> Wx::Window.find_window_by_id(id,self)
> end
> @splitter = @finder.call 'SPLITTER'
> @dummy_panel = @finder.call 'DUMMYPANEL'
> @new_panel = xml.load_panel self,'PANEL'
>
You're loading the new panel as a child of 'self' - the Frame, when it
should be a child of @splitter I think?
> @splitter.replace_window @dummy_panel, @new_panel
In my experience you probably want to follow this with
@dummy_panel.destroy
Otherwise you will be left with the old panel hanging around
hth
alex
More information about the wxruby-users
mailing list