Lazy WxRuby


#1

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.


#2

Hi Trans,

On Mon, Jun 8, 2009 at 4:14 AM, transremoved_email_address@domain.invalid 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.


#3

On Jun 8, 3:20 pm, Chauk-Mean P. removed_email_address@domain.invalid 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.


#4

On Tue, Jun 9, 2009 at 3:27 AM, trans removed_email_address@domain.invalid 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


#5

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


#6

On Jun 17, 7:56 am, Alex F. removed_email_address@domain.invalid 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