[ANN] WxSugar 0.1.2 released

A

Alex Fenton

WxSugar is a set of syntax extensions to sweeten up the WxRuby GUI library.

== INSTALLATION ==

WxSugar is available to download from Rubyforge:
http://rubyforge.org/frs/?group_id=35

Or as a gem:
gem install wxsugar

== PURPOSE ==

WxSugar is a set of pure-ruby syntax extensions which provide a nicer API for using wxRuby, and a testing ground for additions to that library.

wxRuby is under rapid development, and is currently focussed on bringing all the features in the C++ library to Ruby. As such, it suffers a bit from the long and laborious API style typical of C++/Java/etc, rather than the expressive, flexible, succinct style we all like about Ruby.

WxSugar sits on top of either wxruby or wxruby2-preview, and existing code should be able to be run unmodified. When code is rewritten using WxSugar, a reduction of 20-40% in LOC is often seen, but with greater self-documenting niceness.

== FEATURES ==

WxSugar is broken up into different features, each of which comes with complete documentation (mostly... ;). There's a sample illustrating the 'WxSugar style'. If you want it all, just say so:

require 'wx_sugar/all'

Otherwise, you can require individual features separately. Among the most interesting of these:

=== ACCESSORS ===

One C++ inheritance in wxRuby is the pervasive use of method names like get_foo, set_foo, is_foo. Although wxRuby gets rid of the original camelCase, WxSugar goes further in providing ruby-ish accessors:

widget.foo # not widget.get_foo
widget.foo = 'bar' # not widget.set_foo('bar')
widget.foo? # not widget.is_foo


=== KEYWORD CONSTRUCTORS ===

Typical of GUI programming, widget constructors often accept a long list of parameters. Sometimes, you want the default values for all but the last one, but still have to type:

Wx::Button.new(parent, -1, 'Press me', Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::BU_EXACTFIT)

With WxSugar, this becomes:

Wx::Button.new(parent, :label => 'Press me', :style => Wx::BU_EXACTFIT)

=== LAYOUT ===

Sizers are one of wxRuby's most useful features, enabling flexible, resizable window layouts. However, their use is rather complex and takes a lot of typing. WxSugar provides an easier API:

panel.arrange_horizontally do
panel.add(Wx::Button[:label => 'foo'])
panel.add(Wx::Choice[:choices => %w|bar baz qux|], :proportion => 1)
end

=== EVENT CONNECTOR ===

WxSugar adds some neater syntax for hooking up events and handlers:

listen:)button, my_button, :eek:n_my_button_being_pressed)

=== CORE CLASS EXTENSIONS ===

WxSugar also has a small but growing collection of methods added to the core classes, such as Wx::Colour#mix

== FUTURE DIRECTIONS ==

The library will continue being developed, but is very usable now if you like your GUI programming more sweet than salty. Suggestions for new features are welcome, as are patches and contributions.

WxSugar is also a place where the merits of additions to the core wxRuby library can be tested and debated. If you think a feature is good enough to go in the main library and become part of standard wxRuby, just say so on the wxruby mailing list.

General discussion of WxSugar, bug reports and so on are welcome, via the wxruby project.

http://rubyforge.org/projects/wxruby/
 
P

Patrick Hurley

WxSugar is a set of syntax extensions to sweeten up the WxRuby GUI library.

== INSTALLATION ==

WxSugar is available to download from Rubyforge:
http://rubyforge.org/frs/?group_id=35

Or as a gem:
gem install wxsugar

== PURPOSE ==

WxSugar is a set of pure-ruby syntax extensions which provide a nicer API for using wxRuby, and a testing ground for additions to that library.

wxRuby is under rapid development, and is currently focussed on bringing all the features in the C++ library to Ruby. As such, it suffers a bit from the long and laborious API style typical of C++/Java/etc, rather than the expressive, flexible, succinct style we all like about Ruby.

WxSugar sits on top of either wxruby or wxruby2-preview, and existing code should be able to be run unmodified. When code is rewritten using WxSugar, a reduction of 20-40% in LOC is often seen, but with greater self-documenting niceness.

== FEATURES ==

WxSugar is broken up into different features, each of which comes with complete documentation (mostly... ;). There's a sample illustrating the 'WxSugar style'. If you want it all, just say so:

require 'wx_sugar/all'

Otherwise, you can require individual features separately. Among the most interesting of these:

=== ACCESSORS ===

One C++ inheritance in wxRuby is the pervasive use of method names like get_foo, set_foo, is_foo. Although wxRuby gets rid of the original camelCase, WxSugar goes further in providing ruby-ish accessors:

widget.foo # not widget.get_foo
widget.foo = 'bar' # not widget.set_foo('bar')
widget.foo? # not widget.is_foo


=== KEYWORD CONSTRUCTORS ===

Typical of GUI programming, widget constructors often accept a long list of parameters. Sometimes, you want the default values for all but the last one, but still have to type:

Wx::Button.new(parent, -1, 'Press me', Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::BU_EXACTFIT)

With WxSugar, this becomes:

Wx::Button.new(parent, :label => 'Press me', :style => Wx::BU_EXACTFIT)

=== LAYOUT ===

Sizers are one of wxRuby's most useful features, enabling flexible, resizable window layouts. However, their use is rather complex and takes a lot of typing. WxSugar provides an easier API:

panel.arrange_horizontally do
panel.add(Wx::Button[:label => 'foo'])
panel.add(Wx::Choice[:choices => %w|bar baz qux|], :proportion => 1)
end

=== EVENT CONNECTOR ===

WxSugar adds some neater syntax for hooking up events and handlers:

listen:)button, my_button, :eek:n_my_button_being_pressed)

=== CORE CLASS EXTENSIONS ===

WxSugar also has a small but growing collection of methods added to the core classes, such as Wx::Colour#mix

== FUTURE DIRECTIONS ==

The library will continue being developed, but is very usable now if you like your GUI programming more sweet than salty. Suggestions for new features are welcome, as are patches and contributions.

WxSugar is also a place where the merits of additions to the core wxRuby library can be tested and debated. If you think a feature is good enough to go in the main library and become part of standard wxRuby, just say so on the wxruby mailing list.

General discussion of WxSugar, bug reports and so on are welcome, via the wxruby project.

http://rubyforge.org/projects/wxruby/

Looks nice, FYI

gem install wx_sugar

pth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,786
Messages
2,569,626
Members
45,328
Latest member
66Teonna9

Latest Threads

Top