Hi all, where can I find a tutorial like "How to use wxFormbuilder with ruby"? I want to transform xrcise code into ruby code and don''t know how to do this. Thanks! bye Henry -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> where can I find a tutorial like "How to use wxFormbuilder with ruby"? > > I want to transform xrcise code into ruby code and don''t know how to do > this.http://wxruby.rubyforge.org/wiki/wiki.pl?UsingXRCise Note that XRCise doesn''t generate ruby code for the layout - but it writes all the boring code that loads your layout from XML. This means your handwritten classes can concentrate on event handling without having to write heaps of layout code. Any probs, feel free to ask alex
Alex Fenton wrote:> Heinrich Piard wrote: >> where can I find a tutorial like "How to use wxFormbuilder with ruby"? >> >> I want to transform xrcise code into ruby code and don''t know how to do >> this. > > http://wxruby.rubyforge.org/wiki/wiki.pl?UsingXRCise > > Note that XRCise doesn''t generate ruby code for the layout - but it > writes all the boring code that loads your layout from XML. This means > your handwritten classes can concentrate on event handling without > having to write heaps of layout code. > > Any probs, feel free to ask > alexHi Alex, thanks! I prepared everything and started a test but it didn''t work. I created a xrc file and no used xrcise -o test.rm nonam.xrc and get the following error message: Cannot create wrapper for class without ''subclass'' attribute Here the xrc xml: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1"> <object class="wxFrame" name="MyFrame1"> <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style> <size>554,553</size> <title></title> <object class="wxGridSizer"> <rows>500</rows> <cols>3</cols> <vgap>0</vgap> <hgap>0</hgap> </object> <object class="wxStatusBar" name="m_statusBar1"> <style>wxST_SIZEGRIP</style> <fields>1</fields> </object> <object class="wxToolBar" name="m_toolBar1"> <style>wxTB_HORIZONTAL</style> <bitmapsize></bitmapsize> <margins></margins> <packing>1</packing> <separation>5</separation> <object class="wxTextCtrl" name="m_textCtrl1"> <value>enter ticker</value> <maxlength>0</maxlength> </object> <object class="wxButton" name="m_button2"> <pos>-1,-1</pos> <label>Start</label> <default>0</default> </object> <object class="wxButton" name="m_button3"> <label>Stop</label> <default>0</default> </object> </object> </object> </resource> -- Posted via http://www.ruby-forum.com/.
Hello Heinrich, What you will need to do, is goto your main Window form, and scroll down on the properties page, you will see a field that says Subclass, and have a semi-colon in it, with a + next to the field name. You need to click that plus, and put what name you want your ruby class to be named as. EG: MyFrame This will tell XRCise when it generates the wrapper, that the class to use, will be MyFrame. hth, Mario On Fri, Nov 14, 2008 at 12:39 PM, Heinrich Piard <lists at ruby-forum.com>wrote:> Alex Fenton wrote: > > Heinrich Piard wrote: > >> where can I find a tutorial like "How to use wxFormbuilder with ruby"? > >> > >> I want to transform xrcise code into ruby code and don''t know how to do > >> this. > > > > http://wxruby.rubyforge.org/wiki/wiki.pl?UsingXRCise > > > > Note that XRCise doesn''t generate ruby code for the layout - but it > > writes all the boring code that loads your layout from XML. This means > > your handwritten classes can concentrate on event handling without > > having to write heaps of layout code. > > > > Any probs, feel free to ask > > alex > > > Hi Alex, > > thanks! > > I prepared everything and started a test but it didn''t work. > I created a xrc file and no used xrcise -o test.rm nonam.xrc and get the > following error message: > Cannot create wrapper for class without ''subclass'' attribute > > Here the xrc xml: > <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> > <resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1"> > <object class="wxFrame" name="MyFrame1"> > <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style> > <size>554,553</size> > <title></title> > <object class="wxGridSizer"> > <rows>500</rows> > <cols>3</cols> > <vgap>0</vgap> > <hgap>0</hgap> > </object> > <object class="wxStatusBar" name="m_statusBar1"> > <style>wxST_SIZEGRIP</style> > <fields>1</fields> > </object> > <object class="wxToolBar" name="m_toolBar1"> > <style>wxTB_HORIZONTAL</style> > <bitmapsize></bitmapsize> > <margins></margins> > <packing>1</packing> > <separation>5</separation> > <object class="wxTextCtrl" name="m_textCtrl1"> > <value>enter ticker</value> > <maxlength>0</maxlength> > </object> > <object class="wxButton" name="m_button2"> > <pos>-1,-1</pos> > <label>Start</label> > <default>0</default> > </object> > <object class="wxButton" name="m_button3"> > <label>Stop</label> > <default>0</default> > </object> > </object> > </object> > </resource> > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20081114/6ef4b784/attachment.html>
Mario Steele wrote:> Hello Heinrich, > > What you will need to do, is goto your main Window form, and scroll down > on > the properties page, you will see a field that says Subclass, and have a > semi-colon in it, with a + next to the field name. You need to click > that > plus, and put what name you want your ruby class to be named as. > > EG: > MyFrame > > This will tell XRCise when it generates the wrapper, that the class to > use, > will be MyFrame. > > hth, > > MarioGreat! Thanks Mario! bye Henry -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> Mario Steele wrote: >> Hello Heinrich, >> >> What you will need to do, is goto your main Window form, and scroll down >> on >> the properties page, you will see a field that says Subclass, and have a >> semi-colon in it, with a + next to the field name. You need to click >> that >> plus, and put what name you want your ruby class to be named as. >> >> EG: >> MyFrame >> >> This will tell XRCise when it generates the wrapper, that the class to >> use, >> will be MyFrame. >> >> hth, >> >> Mario > > > Great! Thanks Mario! > > > bye > HenryHi all, one more question popped up: 14:37:40: Error: Cannot load resources from file ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in `load'': Failed to load XRC from ''nonam.xrc''; check the file exists and is valid XML (RuntimeError) from test.rb:20:in `initialize'' from test.rb:47:in `new'' from test.rb:47:in `initialize'' from test.rb:50:in `new'' from test.rb:50 The file is in that directory. bye Henry -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> one more question popped up: > > 14:37:40: Error: Cannot load resources from file > ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. > c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in > `load'': Failed to load XRC from ''nonam.xrc''; check the file exists and > is valid XML (RuntimeError)The filename looks a bit suspicious to me. I would expect it to be a valid path rather than a mangled-looking URL. Hard to know where this came from without knowing more about your project layout. I would check that you call xrcise with a relative path, in a typical project structure. Eg I have app.rb lib/*.*/rb share/xrc.xrc I call "xrcise share/xrc.xrc" from the base directory and that means that the paths resolve fine. a
Alex Fenton wrote:> Heinrich Piard wrote: >> one more question popped up: >> >> 14:37:40: Error: Cannot load resources from file >> ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. >> c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in >> `load'': Failed to load XRC from ''nonam.xrc''; check the file exists and >> is valid XML (RuntimeError) > The filename looks a bit suspicious to me. I would expect it to be a > valid path rather than a mangled-looking URL. Hard to know where this > came from without knowing more about your project layout. > > I would check that you call xrcise with a relative path, in a typical > project structure. Eg I have > > app.rb > lib/*.*/rb > share/xrc.xrc > > I call "xrcise share/xrc.xrc" from the base directory and that means > that the paths resolve fine. > > aHello, here is my code. Is still can''t get it to work. # 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: wxFormBuilder\nonam.xrc # Generated at: Fri Nov 14 17:16:34 -0500 2008 require ''wx'' include Wx class CometApplication < Wx::Frame attr_reader :m_statusbar1, :m_toolbar1, :m_textctrl1, :m_button2, :m_button3 def initialize(parent = nil) super() xml = Wx::XmlResource.get xml.flags = 2 # Wx::XRC_NO_SUBCLASSING xml.init_all_handlers xml.load("wxFormBuilder\nonam.xrc") xml.load_frame_subclass(self, parent, "MyFrame1") 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_statusbar1 = finder.call("m_statusBar1") @m_toolbar1 = finder.call("m_toolBar1") @m_textctrl1 = finder.call("m_textCtrl1") @m_button2 = finder.call("m_button2") @m_button3 = finder.call("m_button3") if self.class.method_defined? "on_init" self.on_init() end end end class MyApp < App def initialize() CometApplication.new end end MyApp.new.main_loop() I start the code from C:\ruby\ruby_scripts\test.rb and the xrc file is in C:\ruby\ruby_scripts\wxFormBuilder\nonam.xrc -- Posted via http://www.ruby-forum.com/.
Try changing the line for the loading of the XML resource file from: xml.load("wxFormBuilder\noname.xrc") To: xml.load("wxFormBuilder/noname.xrc") Thankfully, to Ruby and wxWidgets, it doesn''t really need you to use the \ slash to access a file path. Often times, it''s better to run xrcise as such: xrcise -o noname.rb wxFormBuilder/noname.xrc This way, doesn''t matter if it''s on Windows, or Linux, it will be able to find the resources just fine. On Sat, Nov 15, 2008 at 3:11 PM, Heinrich Piard <lists at ruby-forum.com>wrote:> Hello, > > here is my code. Is still can''t get it to work. > > > # 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: wxFormBuilder\nonam.xrc > # Generated at: Fri Nov 14 17:16:34 -0500 2008 > > require ''wx'' > include Wx > > class CometApplication < Wx::Frame > > attr_reader :m_statusbar1, :m_toolbar1, :m_textctrl1, :m_button2, > :m_button3 > > def initialize(parent = nil) > super() > xml = Wx::XmlResource.get > xml.flags = 2 # Wx::XRC_NO_SUBCLASSING > xml.init_all_handlers > xml.load("wxFormBuilder\nonam.xrc") > xml.load_frame_subclass(self, parent, "MyFrame1") > > 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_statusbar1 = finder.call("m_statusBar1") > @m_toolbar1 = finder.call("m_toolBar1") > @m_textctrl1 = finder.call("m_textCtrl1") > @m_button2 = finder.call("m_button2") > @m_button3 = finder.call("m_button3") > if self.class.method_defined? "on_init" > self.on_init() > end > end > end > > class MyApp < App > def initialize() > CometApplication.new > end > end > MyApp.new.main_loop() > > I start the code from C:\ruby\ruby_scripts\test.rb and the xrc file is > in C:\ruby\ruby_scripts\wxFormBuilder\nonam.xrc > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20081115/def6220f/attachment.html>
Mario Steele wrote:> Try changing the line for the loading of the XML resource file from: > > xml.load("wxFormBuilder\noname.xrc") > > To: > > xml.load("wxFormBuilder/noname.xrc") > > Thankfully, to Ruby and wxWidgets, it doesn''t really need you to use the > \ > slash to access a file path. > > Often times, it''s better to run xrcise as such: > > xrcise -o noname.rb wxFormBuilder/noname.xrc > > This way, doesn''t matter if it''s on Windows, or Linux, it will be able > to > find the resources just fine.Hi Mario, changed it but still get this message. 10:33:15: Error: Cannot load resources from file ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in `load'': Failed to load XRC from ''wxFormBuilder/nonam.xrc''; check the file exists and is valid XML (RuntimeError) from test.rb:23:in `initialize'' from test.rb:51:in `new'' from test.rb:51:in `initialize'' from test.rb:54:in `new'' from test.rb:54 Thanks! bye Henry -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> Mario Steele wrote: >> Try changing the line for the loading of the XML resource file from: >> >> xml.load("wxFormBuilder\noname.xrc") >> >> To: >> >> xml.load("wxFormBuilder/noname.xrc") >> >> Thankfully, to Ruby and wxWidgets, it doesn''t really need you to use the >> \ >> slash to access a file path. >> >> Often times, it''s better to run xrcise as such: >> >> xrcise -o noname.rb wxFormBuilder/noname.xrc >> >> This way, doesn''t matter if it''s on Windows, or Linux, it will be able >> to >> find the resources just fine. > > > Hi Mario, > > changed it but still get this message. > > 10:33:15: Error: Cannot load resources from file > ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. > c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in > `load'': Failed to load XRC from ''wxFormBuilder/nonam.xrc''; check the > file exists and is valid XML (RuntimeError) > from test.rb:23:in `initialize'' > from test.rb:51:in `new'' > from test.rb:51:in `initialize'' > from test.rb:54:in `new'' > from test.rb:54 > > Thanks! > > > bye > HenryHi all, could the above errors be caused by a bug? bye Henry -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> Heinrich Piard wrote: > >> Mario Steele wrote: >> >>> Try changing the line for the loading of the XML resource file from: >>> >>> xml.load("wxFormBuilder\noname.xrc") >>> >>> To: >>> >>> xml.load("wxFormBuilder/noname.xrc") >>> >>> >>> >> >> changed it but still get this message. >> >> 10:33:15: Error: Cannot load resources from file >> ''file:/C%3A/ruby/ruby_scripts/wxFormBuilder/nonam.xrc''. >> c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.9-x86-mswin32-60/lib/wx/classes/xmlresource.rb:31:in >> `load'': Failed to load XRC from ''wxFormBuilder/nonam.xrc''; check the >> file exists and is valid XML (RuntimeError) >> > > > > could the above errors be caused by a bug? >It''s possible, but I can''t tell without seeing the XRC file as well as the generated code. Please could you post your own script, the XRC-generated ruby file and the XML source file in a zip attachment, or file it as a bug with attachments on the website bug tracker. thanks alex
Alex Fenton wrote:> Heinrich Piard wrote: >>>> xml.load("wxFormBuilder/noname.xrc") >>> file exists and is valid XML (RuntimeError) >>> >> >> >> >> could the above errors be caused by a bug? >> > > It''s possible, but I can''t tell without seeing the XRC file as well as > the generated code. Please could you post your own script, the > XRC-generated ruby file and the XML source file in a zip attachment, or > file it as a bug with attachments on the website bug tracker. > > thanks > alexHi Alex, I have attached the file in zip format. noname.zip Attachments: http://www.ruby-forum.com/attachment/2935/noname.zip -- Posted via http://www.ruby-forum.com/.
Heinrich Piard wrote:> Alex Fenton wrote: >> Heinrich Piard wrote: >>>>> xml.load("wxFormBuilder/noname.xrc") >>>> file exists and is valid XML (RuntimeError) >>>> >>> >>> >>> >>> could the above errors be caused by a bug? >>> >> >> It''s possible, but I can''t tell without seeing the XRC file as well as >> the generated code. Please could you post your own script, the >> XRC-generated ruby file and the XML source file in a zip attachment, or >> file it as a bug with attachments on the website bug tracker. >> >> thanks >> alex > > Hi Alex, > > I have attached the file in zip format. > > noname.zipHi all, I was able to solve the issue my self. It was a code issue in class MyApp this is how it should look: class MyApp < Wx::App def on_init() Test.new.show() end end MyApp.new.main_loop() Thanks to all! bye Henry -- Posted via http://www.ruby-forum.com/.