WxSugar 0.1.2 released

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, :on_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/

On 10/19/06, Alex F. [email protected] wrote:

== PURPOSE ==

widget.foo? # not widget.is_foo
Wx::Button.new(parent, :label => ‘Press me’, :style => Wx::BU_EXACTFIT)
=== EVENT CONNECTOR ===

Looks nice, FYI

gem install wx_sugar

pth

Alex F. wrote:

== INSTALLATION ==

Or as a gem:
gem install wxsugar

gem install wx_sugar

thanks patrick - just reposted so it’s not after the long message.

The gem is still getting farmed out to Rubyforge mirrors.

alex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs