[wxruby-users] Xrc Q ; using mulitple layouts(Frames , dialogs , panels)
Jn Jn
lists at ruby-forum.com
Wed Nov 19 23:19:43 EST 2008
Problem 1
I had overlooked the error, my bad.
./TestXrc.rb:69:in `find_window_by_id': Error wrapping object; class
`wxFilePickerCtrl' is not supported in wxRuby (NotImplementedError)
from ./TestXrc.rb:69:in `initialize'
from ./TestXrc.rb:77:in `call'
from ./TestXrc.rb:77:in `initialize'
from ./TestWrapperClass.rb:7:in `new'
from ./TestWrapperClass.rb:7:in `initialize'
from TestApp.rb:12:in `call'
from TestApp.rb:12:in `process_event'
from TestApp.rb:12:in `main_loop'
from TestApp.rb:12
As wxruby does not support wxFilePicker, is there an alternative (
and FileDialog (Which I suppose I could have used, is not there on
wxFormbuilder) is there any other alternative?
Problem 2.
I put a textbox+button combo to work around the unavailablity of
filepickerctrl. but now I am in a sort of design issue due lack
understanding on how I can make the dialog a child of frame and from
there I can catch its events
Here is the design
TestXrcWrapperClass << TestXrc(BaseFrame) and
BrowseFileWrapperClass << Browsefile(OpenfileDialog)
TestApp creats TestXrcWrapperClass which create
BrowsefilewarraperClass.
Q. How will I get the close events from dialog to the Frame?
Q. How do I put it into a parent child framework(the Dialog and Base
Frame). ?Is that a better way to go?
Code attached :
==================================================================
TestApp.rb
=================================================================
require 'wx'
require 'TestWrapperClass'
class TestApp < Wx::App
def on_init
TestWrapperClass.new().show
end
end
app = TestApp.new
app.main_loop
==================================================================
TestXrc.rb
=================================================================
# 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 19:29:39 -0800 2008
class TestXrc < Wx::Frame
attr_reader :m_menubar2, :m_file, :m_open, :m_exit, :m_help,
:m_notebook1
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, "TestFrame")
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_file = finder.call("m_file")
@m_open = finder.call("m_open")
@m_exit = finder.call("m_exit")
@m_help = finder.call("m_help")
@m_notebook1 = finder.call("m_notebook1")
if self.class.method_defined? "on_init"
self.on_init()
end
end
end
====================================================================
TestWrapperClass.rb
==================================================================
require 'TestXrc'
require 'BrowseFileWrapperClass'
class TestWrapperClass < TestXrc
def initialize()
super()
evt_menu(@m_open){
@dialog=BrowseFileWrapperClass.new
@dialog.show()
}
evt_menu(@m_exit){exit}
end
end
================================================================
BrowseFileWrapperClass.rb
================================================================
require 'TestXrc'
class BrowseFileWrapperClass < BrowseFile
attr_accessor :filename
def initialize
super()
evt_button(@m_browsefile_button){
@filename=@m_browsefile_text.value
close
}
end
end
--
Posted via http://www.ruby-forum.com/.
More information about the wxruby-users
mailing list