Hi all, i''m having several problems using ''load_panel_subclass'' function. The way i suppose to use it is in main_frame.rb on attached file but i get an arror. could somebody tell me how to use it? I''m working on win xp sp2 ruby 1.8.6 patchlevel 111 wxruby 1.9.8 wx_sugar 0.1.20 thank you all. Fabio. _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Fabio Petrucci wrote:> i''m having several problems using ''load_panel_subclass'' function. > > The way i suppose to use it is in main_frame.rb on attached file but i > get an arror. > > could somebody tell me how to use it?You don''t need to use load_panel_subclass here at all - calling it is an error. The ''CONTATTI'' panel is already part of the overall layout of the frame and so is loaded anyway when the whole frame is loaded. load_panel_subclass is only used for when you have a top-level panel (ie, no parent) defined in your XRC file, and want to load that panel as the child of an arbitrary window. hth alex
Thank you Alex, the problem is related on code organization: The xrc file consist of 1 frame and, inside it, a notebook with 2 folders (panels). Conceptually they are separated objects with their own code and logic. What i need is to separate these entities into their own class for better code organization avoiding to encapsulate them into a external custom proxy class: that''s the reason i used ''load_panel_subclass''. cheers fabio. On Tue, Sep 16, 2008 at 2:28 PM, Alex Fenton <alex at pressure.to> wrote:> Fabio Petrucci wrote: > >> i''m having several problems using ''load_panel_subclass'' function. >> >> The way i suppose to use it is in main_frame.rb on attached file but i get >> an arror. >> >> could somebody tell me how to use it? >> > > You don''t need to use load_panel_subclass here at all - calling it is an > error. The ''CONTATTI'' panel is already part of the overall layout of the > frame and so is loaded anyway when the whole frame is loaded. > > load_panel_subclass is only used for when you have a top-level panel (ie, > no parent) defined in your XRC file, and want to load that panel as the > child of an arbitrary window. > > hth > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080916/b3d8f447/attachment.html>
Fabio> the problem is related on code organization: > > The xrc file consist of 1 frame and, inside it, a notebook with 2 > folders > (panels). > Conceptually they are separated objects with their own code and logic. > > What i need is to separate these entities into their own class for > better > code organization avoiding to encapsulate them into a external custom > proxy > class: that''s the reason i used ''load_panel_subclass''Use Ruby Modules instead of Classes to encapsulate the behaviour of the inner windows, such as your Panel. After the layout has been loaded from XRC, retrieve the panel, and use something like panel.extend(MyPanelBehaviours) To add the logic to it. If needed, you can use Module.extended to do initialize- like work in setting up the Panel. By the way, XRCise will do this automatically for you, if you name your inner windows. hth alex