Lazy WxRuby

If interested I posted an example of how I lazily build a WxRuby
interface for an app. Here’s the link via DZone:

http://www.dzone.com/links/wxruby_for_the_lazy.html

T.

Hi Trans,

On Mon, Jun 8, 2009 at 4:14 AM, trans[email protected] wrote:

If interested I posted an example of how I lazily build a WxRuby
interface for an app. Here’s the link via DZone:

http://www.dzone.com/links/wxruby_for_the_lazy.html

Interesting approach.

Just some comments on wxRuby usage or style :
1/ You don’t need to supply -1 as the ID parameter for a Window (-1 or
Wx::ID_ANY is already the default value).
For a window, the only mandatory parameter is the parent window (the
first parameter).

=>
def notebook
@notebook ||= (
notebook = Wx::Notebook.new(frame_panel)
frame_sizer.add(notebook, 1, Wx::GROW)
notebook
)
end

2/ Wx::Bitmap is smart enough to guess the bitmap type based on the
file extension (OK, it’s not well documented but I’ll fix that).
Wx::Toolbar has also the add_item method which support keyword
arguments (and it’s well documented) :

@search_start_tool = toolbar.add_tool(-1, ‘Start’ ,
Wx::Bitmap.new(DIR + ‘/images/search.gif’,
Wx::BITMAP_TYPE_GIF), ‘Start’)

=>

@search_start_tool = toolbar.add_item(Wx::Bitmap.new(DIR +
‘/images/search.gif’), :label => ‘Start’, :short_help => ‘Start’)

Cheers.

Chauk-Mean.

On Jun 8, 3:20 pm, Chauk-Mean P. [email protected] wrote:

Interesting approach.

Thanks. The approach really helped me wrap my head around WxRuby
better.

    frame_sizer.add(notebook, 1, Wx::GROW)
        Wx::Bitmap.new(DIR + '/images/search.gif',

Wx::BITMAP_TYPE_GIF), ‘Start’)

=>

@search_start_tool = toolbar.add_item(Wx::Bitmap.new(DIR +
‘/images/search.gif’), :label => ‘Start’, :short_help => ‘Start’)

Nice tips. I’ll apply those.

Thanks for taking at look at this.

T.

On Tue, Jun 9, 2009 at 3:27 AM, trans [email protected] wrote:

1/ You don’t need to supply -1 as the ID parameter for a Window (-1 or
)

=>

@search_start_tool = toolbar.add_item(Wx::Bitmap.new(DIR +
‘/images/search.gif’), :label => ‘Start’, :short_help => ‘Start’)

Nice tips. I’ll apply those.

Thanks for taking at look at this.

Perhaps I’m still too lazy for this :slight_smile:
But your approaching is cool

trans wrote:

If interested I posted an example of how I lazily build a WxRuby
interface for an app. Here’s the link via DZone:

http://www.dzone.com/links/wxruby_for_the_lazy.html

Late to the link, but thanks for posting this. I think the approach is
interesting and instructive so I added it to the tutorials page on the
wiki.

Another shortcut you can use:

Wx::VBoxSizer.new

instead of

Wx::BoxSizer.new(Wx::VERTICAL)

alex

On Jun 17, 7:56 am, Alex F. [email protected] wrote:

trans wrote:

If interested I posted an example of how I lazily build a WxRuby
interface for an app. Here’s the link via DZone:

http://www.dzone.com/links/wxruby_for_the_lazy.html

Late to the link, but thanks for posting this. I think the approach is
interesting and instructive so I added it to the tutorials page on the wiki.

Nice :slight_smile:

Another shortcut you can use:

Wx::VBoxSizer.new

instead of

Wx::BoxSizer.new(Wx::VERTICAL)

Thanks, I updated the post to use this.

Btw, just for completeness sake, the Controller class should also have
this method:

def sites ; service.sites ; end

trans