Very cool Alex! I think that would be a good addition to wxSugar.
The only thing that bugs me on the generated code is how long the
attr_reader line is. I made a modified version which allows you to
choose if you want each attr_reader to be on its own line or to wrap
every so many columns.
Sean
On 9/12/07, Alex Fenton <alex at pressure.to>
wrote:> Hi
>
> Attached is a rough draft of a tool that parses XRC files and creates
> skeleton ruby class files from them.
>
> ruby xrc-tool.rb my_frame.xrc > my_frame.rb
>
> At the moment it only deals with Frame/Dialog/Panel subclasses, for
> which it creates a constructor that loads from the XML, and binds the
> named controls in the XML to ruby variables and accessors.
>
> THe idea is that this would make working with a visual designer easier:
> save your XRC files in one directory, run the tool whenever needed (poss
> via rake). Have the actual ruby classes you use (with the hand-written
> event handling code) inherit from these auto-generated files.
>
> I''ll probably tidy up and add to wxSugar.
>
> - Suggestions welcome...
> - Not sure what to do about non-subclass Dialogs/MenuBars/ToolBars etc.
> - Not sure if it deals with all varieties of XRC - I''ve only tried
it on
> listbook.xrc from the wxRuby samples - testing welcome
>
> cheers
> alex
>
> _______________________________________________
> wxruby-development mailing list
> wxruby-development at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-development
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xrc-tool-2.rb
Type: text/x-ruby-script
Size: 3663 bytes
Desc: not available
Url :
http://rubyforge.org/pipermail/wxruby-development/attachments/20070912/e90dfb17/attachment-0001.bin