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<transfire at gmail.com> 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 Proum <chauk.m... at gmail.com> wrote:> > Interesting approach.Thanks. The approach really helped me wrap my head around WxRuby better.> 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'')Nice tips. I''ll apply those. Thanks for taking at look at this. T.
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.htmlLate 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 Fenton <a... at pressure.to> 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 :-)> 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