Hi, i''m evaluating XmlResource: loading frame, dialogs and access widgets is ok but i''m not able to load menu bar and menu using the corresponding methods XmlResource#load_menu_barXmlResource#load_menui get the error saying ''XML resource ''Opzioni'' (class ''wxMenu'') not found!'' trying to load a menu and ''XML resource ''ID_MENUBAR'' (class ''wxMenuBar'') not found!'' trying to load a menu bar. Here is my xml: <?xml version="1.0" encoding="UTF-8"?> <resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc"> <object class="wxFrame" name="ID_NOTIFIER" subclass="notifier"> <style>wxCAPTION|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxCLOSE_BOX</style> <size>300,300</size> <title>wxnc</title> <object class="wxMenuBar" name="ID_MENUBAR"> <object class="wxMenu"> <label>File</label> <object class="wxMenuItem" name="wxID_EXIT"> <label>Esci</label> </object> </object> <object class="wxMenu"> <label>Opzioni</label> <object class="wxMenuItem" name="ID_CONNETTI_AVVIO_MENU_ITEM"> <label>Connetti all''avvio</label> <checkable>1</checkable> </object> </object> </object> ... ... </resource> ..any hints? Thanks! _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
On Wed, 04 Jul 2007 04:05:53 -0500, Fabio Petrucci <fabio.petrucci at gmail.com> wrote:> Hi, > i''m evaluating XmlResource: loading frame, dialogs and access widgets is > ok > but i''m not able to load menu bar and menu using the corresponding > methods > > XmlResource#load_menu_barXmlResource#load_menui get the error saying ''XML > resource ''Opzioni'' (class ''wxMenu'') not found!'' trying to load a menu and > ''XML resource ''ID_MENUBAR'' (class ''wxMenuBar'') not found!'' trying to > load a > menu bar. > > Here is my xml: > > <?xml version="1.0" encoding="UTF-8"?> > <resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc"> > <object class="wxFrame" name="ID_NOTIFIER" subclass="notifier"> > <style>wxCAPTION|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxCLOSE_BOX</style> > <size>300,300</size> > <title>wxnc</title> > <object class="wxMenuBar" name="ID_MENUBAR"> > <object class="wxMenu"> > <label>File</label> > <object class="wxMenuItem" name="wxID_EXIT"> > <label>Esci</label> > </object> > </object> > <object class="wxMenu"> > <label>Opzioni</label> > <object class="wxMenuItem" > name="ID_CONNETTI_AVVIO_MENU_ITEM"> > <label>Connetti all''avvio</label> > <checkable>1</checkable> > </object> > </object> > </object> > ... > ... > </resource> > > ..any hints? > > Thanks!Hey Fabio, I ran into this problem myself, when I was working with wxNotebook, and the subsiquent tabs that are within the notebook. Turns out, that XmlResource will only load Top level items, such as wxFrame, since it''s a top level item. It will not recourse through the frame to get the subsiquent items. What you will need to do, is use the Method to retrive the menu bar from the frame, and find_menu off the menu bar, to retrive the ID''s of it. It''s what I had to use myself to retrive my menus in my code. Example Code: class MyFrame < Wx::Frame def initialize(parent) super() xml.load_frame_subclass(self,nil,"ID_NOTIFIER") MenuExit = self.get_menu_bar.find_menu_item("File","Esci") MenuCheck = self.get_menu_bar.find_menu_item("Opzioni","Connetti all''avvio") end end Just my example of how I did it. -- Using Opera''s revolutionary e-mail client: http://www.opera.com/mail/
On 7/4/07, Mario Steele <mario at ruby-im.net> wrote:> > On Wed, 04 Jul 2007 04:05:53 -0500, Fabio Petrucci > <fabio.petrucci at gmail.com> wrote: > > > Hi, > > i''m evaluating XmlResource: loading frame, dialogs and access widgets is > > ok > > but i''m not able to load menu bar and menu using the corresponding > > methods > > > > XmlResource#load_menu_barXmlResource#load_menui get the error saying > ''XML > > resource ''Opzioni'' (class ''wxMenu'') not found!'' trying to load a menu > and > > ''XML resource ''ID_MENUBAR'' (class ''wxMenuBar'') not found!'' trying to > > load a > > menu bar. > > > > Here is my xml: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc"> > > <object class="wxFrame" name="ID_NOTIFIER" subclass="notifier"> > > > <style>wxCAPTION|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxCLOSE_BOX</style> > > <size>300,300</size> > > <title>wxnc</title> > > <object class="wxMenuBar" name="ID_MENUBAR"> > > <object class="wxMenu"> > > <label>File</label> > > <object class="wxMenuItem" name="wxID_EXIT"> > > <label>Esci</label> > > </object> > > </object> > > <object class="wxMenu"> > > <label>Opzioni</label> > > <object class="wxMenuItem" > > name="ID_CONNETTI_AVVIO_MENU_ITEM"> > > <label>Connetti all''avvio</label> > > <checkable>1</checkable> > > </object> > > </object> > > </object> > > ... > > ... > > </resource> > > > > ..any hints? > > > > Thanks! > > Hey Fabio, > > I ran into this problem myself, when I was working with wxNotebook, and > the subsiquent tabs that are within the notebook. Turns out, that > XmlResource will only load Top level items, such as wxFrame, since it''s a > top level item. It will not recourse through the frame to get the > subsiquent items. What you will need to do, is use the Method to retrive > the menu bar from the frame, and find_menu off the menu bar, to retrive > the ID''s of it. It''s what I had to use myself to retrive my menus in my > code. > > Example Code: > > class MyFrame < Wx::Frame > def initialize(parent) > super() > xml.load_frame_subclass(self,nil,"ID_NOTIFIER") > MenuExit = self.get_menu_bar.find_menu_item("File","Esci") > MenuCheck = self.get_menu_bar.find_menu_item > ("Opzioni","Connetti > all''avvio") > end > end > > > Just my example of how I did it. > > > -- > Using Opera''s revolutionary e-mail client: http://www.opera.com/mail/ > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >Thank you Mario, i had the same problem loading notebook''s pages into subclass of the same type (for a cleaner code) but i had to give up. For the menu i think to adopt your solution. thanks again. fabio. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070704/ef6807be/attachment-0001.html
Hi Fabio Fabio Petrucci wrote:> Hi, > i''m evaluating XmlResource: loading frame, dialogs and access widgets > is ok but i''m not able to load menu bar and menu using the > corresponding methodsI think the problem with the XRC file you attached is that it describes a Wx::Frame, not a Wx::MenuBar. I don''t think it''s permitted to load a MenuBar from within a bigger XRC description of another class. I''ve attached below a modified version of your XRC that works for me using load_menu_bar. You should also check that you''re using #load(filename) to load up the correct file first. If you wanted to load a complete frame layout including a MenuBar, as in your original file, you should use load_frame (or load_frame_subclass) instead. hth alex <?xml version="1.0" encoding="ISO-8859-1"?> <resource xmlns="http://www.wxwidgets.org/wxxrc"> <object class="wxMenuBar" name="ID_MENUBAR"> <object class="wxMenu"> <label>File</label> <object class="wxMenuItem" name="wxID_EXIT"> <label>Esci</label> </object> </object> <object class="wxMenu"> <label>Opzioni</label> <object class="wxMenuItem" name="ID_CONNETTI_AVVIO_MENU_ITEM"> <label>Connetti all''avvio</label> <checkable>1</checkable> </object> </object> </object> </resource>
Mario Steele wrote:> I ran into this problem myself, when I was working with wxNotebook, and > the subsiquent tabs that are within the notebook. Turns out, that > XmlResource will only load Top level items, such as wxFrame, since it''s a > top level item.Sorry, I missed your answer Mario - I think this is the problem with Fabio''s XRC - ie that the root <object> item in the XRC must be the one being loaded. But I think you should be able to load individual tabs within a Notebook using load_panel or load_panel_subclass. For convenience, I''ve altered XmlResource#load so that it raises an exception if loading a file failed (eg file didn''t exist, or invalid XML), rather than failing silently. a
On Wed, 04 Jul 2007 11:12:00 -0500, Alex Fenton <alex at pressure.to> wrote:> Mario Steele wrote: >> I ran into this problem myself, when I was working with wxNotebook, and >> the subsiquent tabs that are within the notebook. Turns out, that >> XmlResource will only load Top level items, such as wxFrame, since it''s >> a >> top level item. > Sorry, I missed your answer Mario - I think this is the problem with > Fabio''s XRC - ie that the root <object> item in the XRC must be the one > being loaded. > > But I think you should be able to load individual tabs within a Notebook > using load_panel or load_panel_subclass. > > For convenience, I''ve altered XmlResource#load so that it raises an > exception if loading a file failed (eg file didn''t exist, or invalid > XML), rather than failing silently. > > a > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-usersThis is what I am saying Alex, wxRuby''s XmlResource loader, will not allow you to load subitems on demand. Trust me, I''ve looked through the code, and it''s one of the downfalls to using wxGlade with wxRuby2, it will not load sub-controls on demand. I was using it, so I could have a single control definition in the XRC for my client, and it wouldn''t generate copies of the tab on demand, but it wouldn''t do that, so I had to go to generating it manually. Mario Steele -- Using Opera''s revolutionary e-mail client: http://www.opera.com/mail/