[wxruby-users] xml.load_panel
Max Salov
lists at ruby-forum.com
Wed Aug 27 02:07:15 EDT 2008
Alex Fenton wrote:
> Max Salov wrote:
>> If I load panel directly from xrc-file, everything is ok, but if I
>> create a class
>>
>> class NewPanel < Wx::Panel
>> def initialize parent = nil
>> super
>>
> Here, you must call super() - with no arguments. Whenever you're loading
> an XRC layout into a Frame/Panel/Dialog subclass you must call the
> default initialize with no arguments, then call load_xxx_subclass with
> the usual arguments.
>
>> $xml.load_panel_subclass(self,parent,'PANEL')
>> end
>> end
>>
>
> cheers
> aelx
Hm, 'super()' call raises error in NewPanel#initalize, while in
MainFrame#initialize it works perfectly.
c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.7-i386-mswin32/lib/wx/keyword_ctors.rb:180:in
`pre_wx_kwctor_init': wrong # of arguments(0 for 1) (ArgumentError)
from
c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.7-i386-mswin32/lib/wx/keyword_ctors.rb:180:in
`initialize'
from ./newpanel.rb:3:in `initialize'
from test.rb:21:in `new'
from test.rb:21:in `initialize'
from test.rb:35:in `new'
from test.rb:35:in `on_init'
from
c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.7-i386-mswin32/lib/wx/classes/app.rb:16:in
`main_loop'
from
c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.7-i386-mswin32/lib/wx/classes/app.rb:16:in
`run'
from test.rb:29
And one more question regarding events. What happens to events,
assosiated to destroyed objects?
my_button = Wx::Button.new self
evt_button my_button, :my_button_click
my_button.destroy
Is this code ok, or I have to disconnect event first?
my_button = Wx::Button.new self
evt_button my_button, :my_button_click
disconnect my_button, Wx::ID_ANY, :evt_button
my_button.destroy
Max
--
Posted via http://www.ruby-forum.com/.
More information about the wxruby-users
mailing list