From lists at ruby-forum.com Tue Sep 2 10:47:46 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Tue, 2 Sep 2008 16:47:46 +0200 Subject: [wxruby-users] Two issues using GridBagSizer Message-ID: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> I am having a couple of issues with sizing objects using GridBagSizer. The first is that the GridBagSizer itself isn't expanding to fill the area available to it. For reasons that will be more clear when I get to the second issue, the GridBagSizer actually has only one cell. When I add the panel sized with the GridBagSizer to the BoxSizer that holds it, I use the EXPAND flag, but it doesn't expand to fill the entire horizontal area (see attached image, top half). The second problem relates to the way I'm using the GridBagSizer. It contains only a single cell that has two separate panels in it. These panels are mutually exclusive (either one or the other is showing, or possibly neither, but never both), so I want them to occupy the same space, which works using the GridBagSizer. When I first executed the code, the contents of @add_panel and @edit_panel would both be squished into a very small area at the upper-left corner of the @option_panel. At position 1 in the code, I added the following lines: @option_sizer.calc_min @option_sizer.recalc_sizes This fixed the problem for the @add_panel only-- at edit_panel would still appear squished into the corner. I then moved the two lines to appear at both position 2 and position 3 in the code, but the problem persisted (see attached image, bottom half). [ui/detail_panel.rb]: require 'wx' require 'ui/add_panel' require 'ui/edit_panel' include Wx class DetailPanel < Panel def initialize(parent) super parent @box = StaticBox.new self, :label => 'Entry Detail View' ... # creating other frames @option_panel = Panel.new self @add_panel = AddEntryPanel.new @option_panel @edit_panel = EditEntryPanel.new @option_panel @main_sizer = BoxSizer.new VERTICAL set_sizer @main_sizer @box_sizer = StaticBoxSizer.new @box, VERTICAL ... # defining other sizers @option_sizer = GridBagSizer.new @option_panel.set_sizer @option_sizer @main_sizer.add @box_layout, 1, EXPAND|LEFT|RIGHT, 1 ... # adding other frames to @box_sizer @box_sizer.add @option_panel, 1, EXPAND|TOP, 6 ... # other sizers within @box_sizer @option_sizer.add @add_panel, GBPosition.new(0, 0), GBSpan.new, EXPAND @option_sizer.add @edit_panel, GBPosition.new(0, 0), GBSPan.new, EXPAND #position 1 ... # assign event handlers show @add_panel.hide @edit_panel.hide end def add_button_click(event) @edit_panel.hide @add_panel.show #position 2 end def edit_button_click(event) @add_panel.hide @edit_panel.show #position 3 end end ui/add_panel.rb and ui/entry_panel.rb contain the necessary class definitions for those AddPanel and EntryPanel, of course. Any help (including complete overhauls if there's a better way I should be doing this) is welcome. Thanks, Doug G. Attachments: http://www.ruby-forum.com/attachment/2640/non-expand.jpg -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 2 12:06:11 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 02 Sep 2008 17:06:11 +0100 Subject: [wxruby-users] Two issues using GridBagSizer In-Reply-To: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> References: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> Message-ID: <48BD6473.4030700@pressure.to> Hi Doug Glidden wrote: > The first is that the GridBagSizer itself isn't expanding to fill the > area available to it. For reasons that will be more clear when I get to > the second issue, the GridBagSizer actually has only one cell. When I > add the panel sized with the GridBagSizer to the BoxSizer that holds it, > I use the EXPAND flag, but it doesn't expand to fill the entire > horizontal area (see attached image, top half). > I couldn't fully follow what was going on in your code, but hope I can help with a few suggestions: * Try using one of the GUI designers (eg DialogBlocks) to test build your layout. They make it easy to swap and nest Sizers and you can immediately see the effects. From then you can go and look at the XML to see how the Sizers are flagged and nested. * Use a com > The second problem relates to the way I'm using the GridBagSizer. It > contains only a single cell that has two separate panels in it. Why are you using GridBagSizer then? If all you want is a place to swap two panels or widgets in and out of, a simple BoxSizer would do fine. Have a look at Sizer#detach and Sizer#replace methods, in conjunction with using Window#hide or Window#destroy on the window you're removing. > These > panels are mutually exclusive (either one or the other is showing, or > possibly neither, but never both), so I want them to occupy the same > space, which works using the GridBagSizer. Ok, see suggestion above. Here's a simple class which wraps multiple controls, presenting only one at a time. > When I first executed the > code, the contents of @add_panel and @edit_panel would both be squished > into a very small area at the upper-left corner of the @option_panel. > At position 1 in the code, I added the following lines: > > @option_sizer.calc_min > @option_sizer.recalc_sizes > > This fixed the problem for the @add_panel only-- at edit_panel would still > appear squished into the corner. I then moved the two lines to appear > at both position 2 and position 3 in the code, but the problem persisted > (see attached image, bottom half). > > [ui/detail_panel.rb]: > require 'wx' > require 'ui/add_panel' > require 'ui/edit_panel' > include Wx > > class DetailPanel < Panel > def initialize(parent) > super parent > > @box = StaticBox.new self, :label => 'Entry Detail View' > ... # creating other frames > @option_panel = Panel.new self > @add_panel = AddEntryPanel.new @option_panel > @edit_panel = EditEntryPanel.new @option_panel > > @main_sizer = BoxSizer.new VERTICAL > set_sizer @main_sizer > @box_sizer = StaticBoxSizer.new @box, VERTICAL > ... # defining other sizers > @option_sizer = GridBagSizer.new > @option_panel.set_sizer @option_sizer > > @main_sizer.add @box_layout, 1, EXPAND|LEFT|RIGHT, 1 > > ... # adding other frames to @box_sizer > @box_sizer.add @option_panel, 1, EXPAND|TOP, 6 > > ... # other sizers within @box_sizer > > @option_sizer.add @add_panel, GBPosition.new(0, 0), GBSpan.new, > EXPAND > @option_sizer.add @edit_panel, GBPosition.new(0, 0), GBSPan.new, > EXPAND > #position 1 > > ... # assign event handlers > show > @add_panel.hide > @edit_panel.hide > end > > def add_button_click(event) > @edit_panel.hide > @add_panel.show > #position 2 > end > > def edit_button_click(event) > @add_panel.hide > @edit_panel.show > #position 3 > end > end > > ui/add_panel.rb and ui/entry_panel.rb contain the necessary class > definitions for those AddPanel and EntryPanel, of course. > > Any help (including complete overhauls if there's a better way I should > be doing this) is welcome. > > Thanks, > Doug G. > > Attachments: > http://www.ruby-forum.com/attachment/2640/non-expand.jpg > > From alex at pressure.to Tue Sep 2 12:09:29 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 02 Sep 2008 17:09:29 +0100 Subject: [wxruby-users] Two issues using GridBagSizer In-Reply-To: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> References: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> Message-ID: <48BD6539.5050707@pressure.to> Sorry, hit send too early... The example class you might look at is: http://weft-qda.rubyforge.org/svn/trunk/weft-qda/lib/weft/wxgui/controls/multitype_control.rb Note that when swapping items in and out of a Sizer, you should probably call layout() afterwards to readjust the relative spacing. > The first is that the GridBagSizer itself isn't expanding to fill the > area available to it. For reasons that will be more clear when I get to > the second issue, the GridBagSizer actually has only one cell. When I > add the panel sized with the GridBagSizer to the BoxSizer that holds it, > I use the EXPAND flag, but it doesn't expand to fill the entire > horizontal area (see attached image, top half). > * As for the expansion, you probably want to check that all the inner widgets are also set to expand within their parent. So in the case of your short textcontrols in the upper pane, they may need to be told to expand to full width. > @option_panel = Panel.new self > Note that if a Window is the sole child of a managed Frame it will resize automatically to fill that Frame. You don't need to put it within a sizer. hth alex From lists at ruby-forum.com Tue Sep 2 12:47:39 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Tue, 2 Sep 2008 18:47:39 +0200 Subject: [wxruby-users] Two issues using GridBagSizer In-Reply-To: <48BD6473.4030700@pressure.to> References: <10fe5da0578ec51f5a3d27994096e1fc@ruby-forum.com> <48BD6473.4030700@pressure.to> Message-ID: <840192f6284719f4569baeba9e650266@ruby-forum.com> Alex Fenton wrote: [snip] > Why are you using GridBagSizer then? If all you want is a place to swap > two panels or widgets in and out of, a simple BoxSizer would do fine. > Have a look at Sizer#detach and Sizer#replace methods, in conjunction > with using Window#hide or Window#destroy on the window you're removing. > [snip] Alex, Perfect! I used a BoxSizer and added detach calls to the button_click event handlers. Hadn't discovered the detach method previously. That solved both problems. Thanks for your help! Doug -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Sep 2 14:08:41 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Tue, 2 Sep 2008 20:08:41 +0200 Subject: [wxruby-users] Lack of proper expansion using FlexGridSizer Message-ID: <41ac0afecf276f8c78d541c9dfda404f@ruby-forum.com> I experienced a problem similar to this using GridBagSizer earlier today (http://www.ruby-forum.com/topic/164539#new). The problem was resolved at that point by using a BoxSizer instead of the GridBagSizer, but now I've run into the same problem with a FlexGridSizer. In the top half of the attached image, I use a series of horizontal BoxSizers, each with a StaticText (proportion = 0) and a TextCtrl (proportion = 1). This fills up the space nicely, but I want the left sides of the TextCtrls to line up. Keeping the BoxSizers and changing the proportions to something like 1 and 4 instead of 0 and 1 works, but it leaves large gaps between the label and the textbox when the window is large and lets the textbox unnecessarily force the labels to wrap when the window is smaller. Using a FlexGridSizer accomplishes the goal, but the TextCtrls no longer fill up the available space. The source looks something like this: require 'wx' include Wx class AddPanel < Panel DEFAULT_FIELDS = ["A Label", "Another Label", "A third label", "And so on..."] def initialize(parent) super parent @fields = {} @field_panels = {} @field_labels = {} @field_textboxes = {} @field_layouts = FlexGridSizer.new 2 set_sizer @field_layouts DEFAULT_FIELDS.each do |label| @fields[label] = '' @field_labels[label] = StaticText.new self, :label => label @field_textboxes[label] = TextCtrl.new self, :value => @fields[label] @field_layouts.add @field_labels[label], 0, EXPAND @field_layouts.add @field_textboxes[label], 1, LEFT, 4 ... end show end ... end In the larger Window, the following code is relevant: @add_panel = AddPanel.new @parent_panel ... @option_layout = BoxSizer.new VERTICAL @option_panel.set_sizer @option_layout ... @option_layout.add @add_panel, 1, EXPAND @add_panel.show ... @option_layout.layout Any suggestions? The only other option I can think of is to use a single horizontal BoxSizer with two vertical BoxSizers inside--one with all of the StaticTexts on the left, and the other with all of the TextCtrls on the right. This could potentially cause mis-alignment between the labels and their corresponding fields (if a label gets forced to wrap), though, so I'd rather avoid it. Thanks, Doug Attachments: http://www.ruby-forum.com/attachment/2641/expand-vs-lineup.jpg -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 2 14:59:34 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 02 Sep 2008 19:59:34 +0100 Subject: [wxruby-users] Lack of proper expansion using FlexGridSizer In-Reply-To: <41ac0afecf276f8c78d541c9dfda404f@ruby-forum.com> References: <41ac0afecf276f8c78d541c9dfda404f@ruby-forum.com> Message-ID: <48BD8D16.10800@pressure.to> Doug Glidden wrote: > I experienced a problem similar to this using GridBagSizer earlier today > (http://www.ruby-forum.com/topic/164539#new). The problem was resolved > at that point by using a BoxSizer instead of the GridBagSizer, but now > I've run into the same problem with a FlexGridSizer. In the top half of > the attached image, I use a series of horizontal BoxSizers, each with a > StaticText (proportion = 0) and a TextCtrl (proportion = 1). This fills > up the space nicely, but I want the left sides of the TextCtrls to line > up. > ... > Any suggestions? FlexGridSizer is the right type of sizer for that sort of layout. Maybe look at FlexGridSizer#add_growable_col ? http://wxruby.rubyforge.org/doc/flexgridsizer.html#FlexGridSizer_addgrowablecol alex From lists at ruby-forum.com Tue Sep 2 15:15:49 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Tue, 2 Sep 2008 21:15:49 +0200 Subject: [wxruby-users] Lack of proper expansion using FlexGridSizer In-Reply-To: <48BD8D16.10800@pressure.to> References: <41ac0afecf276f8c78d541c9dfda404f@ruby-forum.com> <48BD8D16.10800@pressure.to> Message-ID: <6093d64fd5e80227f6de53fbb86baaae@ruby-forum.com> Alex Fenton wrote: [snip] > Maybe look at FlexGridSizer#add_growable_col ? [snip] Alex, Thanks, that (combined with using the EXPAND flag when adding @field_textboxes[label] to @field_layouts) did the trick. Doug -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Sep 4 13:56:12 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 04 Sep 2008 18:56:12 +0100 Subject: [wxruby-users] wxRuby 1.9.8, windows gem available Message-ID: <48C0213C.5080500@pressure.to> Hi A binary wxRuby 1.9.8 gem for Ruby 1.8 on Windows is now available from http://rubyforge.org/frs/?group_id=35 or by doing "gem install wxruby" This should be significantly better than 1.9.7, so upgrading is recommended. Sorry for the delay; it took a while to find the most suitable compiler version. This was built with MSVC 7.1 (Visual Studio 2003). alex From lists at ruby-forum.com Mon Sep 8 01:42:47 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Mon, 8 Sep 2008 07:42:47 +0200 Subject: [wxruby-users] select_all method missing in HtmlWindow Message-ID: Hi, Thanks for great work getting 1.9.8 release out. I got the following errors for HtmlWindow undefined method 'select_all' for # undefined method 'selection_to_text' for # Doc: http://wxruby.rubyforge.org/doc/htmlwindow.html#HtmlWindow_selectall Env: Ruby 1.8.6, wxRuby mingw32 1.9.8 Regards, Zhimin -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Sep 8 03:28:54 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 08 Sep 2008 08:28:54 +0100 Subject: [wxruby-users] select_all method missing in HtmlWindow In-Reply-To: References: Message-ID: <48C4D436.8010103@pressure.to> Zhimin Zhan wrote: > I got the following errors for HtmlWindow > undefined method 'select_all' for # > undefined method 'selection_to_text' for # > Thanks for reporting this - this is now fixed in Subversion (SVN:1816) for the next release. cheers alex From lists at ruby-forum.com Mon Sep 8 11:40:02 2008 From: lists at ruby-forum.com (Jim flip) Date: Mon, 8 Sep 2008 17:40:02 +0200 Subject: [wxruby-users] render natively Message-ID: I would like to render natively i.e. via a C dll that I have wrapped using SWIK. So I want my c code to receive a buffer that it can render to, and then have WXruby display this memory buffer/bitmap. Can anyone advise me what would be the best method for doing this, to save me having to find out the hard way. Many thanks, Jim. -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Mon Sep 8 12:31:50 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 08 Sep 2008 17:31:50 +0100 Subject: [wxruby-users] render natively In-Reply-To: References: Message-ID: <48C55376.20901@pressure.to> Jim flip wrote: > I would like to render natively i.e. via a C dll that I have wrapped > using SWIK. > > So I want my c code to receive a buffer that it can render to, and then > have WXruby display this memory buffer/bitmap. > A drawing context (whether an in-memory buffer, an on-screen canvas, or a printout) is represented by a DC [1] instance in wxRuby. MemoryDC is the specific class for in-memory buffers. However the API and class is cross-platform and specific to WxRuby, so you're not going to be able to pass this in directly to your dll. You don't give a lot of info about the way your API works, but I'd think probably the easiest way would be to have your dll render to a ruby String in a recognised image format (wxRuby understands PNG, TIF, JPG, BMP, TGA) then wrap this in a ruby StringIO object. Call Wx::Image.read [2] to load this image into an object, then do Wx::Bitmap.from_image to convert it to a windows bitmap that can be rendered on screen. Lastly, simple draw this onto a window surface using its paint method. Have a look at the example in samples/drawing/image.rb to see the basics of writing an image to screen. > Can anyone advise me what would be the best method for doing this, to > save me having to find out the hard way. > This should probably work, but there's a few other options should this not be suitable. Also have a search through the archives as there have been a few threads about rendering images from external libraries (eg ImageMagick). cheers alex [1] http://wxruby.rubyforge.org/doc/dc.html [2] http://wxruby.rubyforge.org/doc/image.html#Image_read From lists at ruby-forum.com Tue Sep 9 05:29:16 2008 From: lists at ruby-forum.com (Jim flip) Date: Tue, 9 Sep 2008 11:29:16 +0200 Subject: [wxruby-users] render natively In-Reply-To: <48C55376.20901@pressure.to> References: <48C55376.20901@pressure.to> Message-ID: Thanks for the pointers, I think I will try using a bitmap and it's set_data method as this should be simple to try out but may be a bit slow. Thanks, Jim. -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 9 05:40:34 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 09 Sep 2008 10:40:34 +0100 Subject: [wxruby-users] render natively In-Reply-To: References: <48C55376.20901@pressure.to> Message-ID: <48C64492.3080003@pressure.to> Jim flip wrote: > Thanks for the pointers, I think I will try using a bitmap and it's > set_data method as this should be simple to try out but may be a bit > slow. > If you can avoid composing or decomposing the image data in Ruby (using pack etc) this will be pretty fast - for example, if you can get your extension to emit image data in that format. Then it's just a C-level memcpy going on. Similarly Image.read should be fast if you can get your extension to produce a known image format. These wxRuby methods are not particularly far off the native C library functions in libtiff, libpng etc alex From lists at ruby-forum.com Tue Sep 9 06:46:13 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Tue, 9 Sep 2008 12:46:13 +0200 Subject: [wxruby-users] drag_accept_files undefined in 1.9.8 (mingw32) Message-ID: <7316c3b04d40bbad92389eb158562eb4@ruby-forum.com> Hi, I got "undefined method 'drag_accept_files' for Wx::Frame" The doc (http://wxruby.rubyforge.org/doc/window.html#Window_dragacceptfiles) indicates it's available on Windows. Thanks, Zhimin -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 9 06:55:18 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 09 Sep 2008 11:55:18 +0100 Subject: [wxruby-users] drag_accept_files undefined in 1.9.8 (mingw32) In-Reply-To: <7316c3b04d40bbad92389eb158562eb4@ruby-forum.com> References: <7316c3b04d40bbad92389eb158562eb4@ruby-forum.com> Message-ID: <48C65616.1070600@pressure.to> Zhimin Zhan wrote: > I got "undefined method 'drag_accept_files' for Wx::Frame" > > The doc > (http://wxruby.rubyforge.org/doc/window.html#Window_dragacceptfiles) > indicates it's available on Windows. > Thanks for reporting this. It's not in our SVN. We could add it, but the wxWidgets docs suggest it's 1) Windows only 2) Based on an older Windows system http://docs.wxwidgets.org/2.8.6/wx_wxdropfilesevent.html You should already be able to drag/drop files using DropFileTarget (take a look at samples/dragdrag/dragdrop.rb) If you think there is something that drag_accept_files would add to the more general drag/drop features already available, let me know, otherwise I will delete references to this from the docs. cheers alex From lists at ruby-forum.com Tue Sep 9 18:32:37 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Wed, 10 Sep 2008 00:32:37 +0200 Subject: [wxruby-users] drag_accept_files undefined in 1.9.8 (mingw32) In-Reply-To: <48C65616.1070600@pressure.to> References: <7316c3b04d40bbad92389eb158562eb4@ruby-forum.com> <48C65616.1070600@pressure.to> Message-ID: <05c8aee430b30b9f8f8face50fea3c59@ruby-forum.com> Alex Fenton wrote: > You should already be able to drag/drop files using DropFileTarget (take > a look at samples/dragdrag/dragdrop.rb) That's exactly what I wanted, Thanks! Regards, Zhimin -- Posted via http://www.ruby-forum.com/. From erubin at valcom.com Wed Sep 10 13:21:11 2008 From: erubin at valcom.com (Eric Rubin) Date: Wed, 10 Sep 2008 13:21:11 -0400 Subject: [wxruby-users] Crash after calling set_size In-Reply-To: <05c8aee430b30b9f8f8face50fea3c59@ruby-forum.com> Message-ID: <06F2A4EE002A45369826F0BE31D8A9C3@valcom.com> I'm trying to track down a mysterious crash that has cropped up in my WxRuby app. It occurs only after I call set_size to reduce the size of my Frame. The message I get when it crashes is: "This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.", which I think means there was an unhandled exception. Is there any problem with reducing the size of a Frame so that there are controls that are no long visible? (It seems like the problem doesn't occur if I manually reduce the size of Frame by dragging the border.) Any suggestions would be appreciated. Eric Rubin From rw at iclway.co.uk Wed Sep 10 13:51:50 2008 From: rw at iclway.co.uk (unknown unknown) Date: Wed, 10 Sep 2008 18:51:50 +0100 Subject: [wxruby-users] require fails with undefined symbol Message-ID: I have installed wxruby via gems on Ubuntu 7.10 but running sample/minimal.rb fails: ruby -rubygems minimal.rb /var/lib/gems/1.8/gems/wxruby-1.9.8-x86-linux/lib/wxruby2.so: /var/lib/gems/1.8/gems/wxruby-1.9.8-x86-linux/lib/wxruby2.so: undefined symbol: g_assertion_message_expr - /var/lib/gems/1.8/gems/wxruby-1.9.8-x86-linux/lib/wxruby2.so (LoadError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in `require' from /var/lib/gems/1.8/gems/wxruby-1.9.8-x86-linux/lib/wx.rb:12 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in `require' from minimal.rb:8 Any help (hopefully without recourse to source compilation) would be very welcome. Thanks, Richard W From lists at ruby-forum.com Thu Sep 11 15:26:05 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Thu, 11 Sep 2008 21:26:05 +0200 Subject: [wxruby-users] StaticText wrap method missing? Message-ID: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> The wxRuby documentation claims there is a StaticText#wrap method, but it seems to be missing (using wxRuby 1.9.8). I am unable to use it, and it does not appear in the results of either Wx::StaticText.methods or Wx::StaticText.instance_methods. Is this something that is yet-to-be-implemented? Thanks, Doug -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Fri Sep 12 07:49:11 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 12 Sep 2008 12:49:11 +0100 Subject: [wxruby-users] StaticText wrap method missing? In-Reply-To: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> References: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> Message-ID: <48CA5737.5020907@pressure.to> Hi Doug Glidden wrote: > The wxRuby documentation claims there is a StaticText#wrap method, but > it seems to be missing (using wxRuby 1.9.8). I am unable to use it, and > it does not appear in the results of either Wx::StaticText.methods or > Wx::StaticText.instance_methods. Is this something that is > yet-to-be-implemented? Thanks for reporting this. It's already fixed in SVN, but it missed the cut for 1.9.8. It'll be available for the next release, or if you want to build your own from the repository. cheers alex From lists at ruby-forum.com Fri Sep 12 08:27:30 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Fri, 12 Sep 2008 14:27:30 +0200 Subject: [wxruby-users] StaticText wrap method missing? In-Reply-To: <48CA5737.5020907@pressure.to> References: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> <48CA5737.5020907@pressure.to> Message-ID: <520963e139727c7a49d14f026a84cbd1@ruby-forum.com> Alex Fenton wrote: [snip] > Thanks for reporting this. It's already fixed in SVN, but it missed the > cut for 1.9.8. It'll be available for the next release, or if you want > to build your own from the repository. > > cheers > alex Alex, Thanks. Do you have any idea how soon the next release will be coming out? (I'm guessing from the past that it will be around December/January.) Doug -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Fri Sep 12 10:03:46 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 12 Sep 2008 15:03:46 +0100 Subject: [wxruby-users] StaticText wrap method missing? In-Reply-To: <520963e139727c7a49d14f026a84cbd1@ruby-forum.com> References: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> <48CA5737.5020907@pressure.to> <520963e139727c7a49d14f026a84cbd1@ruby-forum.com> Message-ID: <48CA76C2.30706@pressure.to> Doug Glidden wrote: > Do you have any idea how soon the next release will be coming > out? (I'm guessing from the past that it will be around > December/January.) We've slowed from ~6 weeks to more like ~3 months as things have stabilised. But the intention is that the next release is 2.0 and fixes all the high priority items on the tracker. With one or two I don't fully know what needs to be done, so it's a bit uncertain - but December might not be a bad guess. With MingW on Windows, there's now a fairly straightforward process to build your own on all platforms. Current changes are conservative, so SVN tends to be as stable as the release versions. cheers alex From lists at ruby-forum.com Fri Sep 12 12:33:41 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Fri, 12 Sep 2008 18:33:41 +0200 Subject: [wxruby-users] alternative to destroying a dialog? (to avoid segfault) Message-ID: <887343af831ddf9b4c05075a272057e5@ruby-forum.com> Hi, I'm running into a problem with a segfault when destroying a Dialog, which I've read is a known problem that occurs when the GC cleans up after a Dialog that contains a Sizer is destroyed (that's exactly my situation). I don't get a segfault when I remove the destroy call, but the app doesn't exit correctly, either--the process silently hangs. Is there an alternative to destroy or something I can do to avoid the segfault? Thanks, Doug -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Sep 12 12:36:47 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Fri, 12 Sep 2008 18:36:47 +0200 Subject: [wxruby-users] StaticText wrap method missing? In-Reply-To: <48CA76C2.30706@pressure.to> References: <8f5e1d7f3afe990dd78499c373880358@ruby-forum.com> <48CA5737.5020907@pressure.to> <520963e139727c7a49d14f026a84cbd1@ruby-forum.com> <48CA76C2.30706@pressure.to> Message-ID: Alex Fenton wrote: [snip] > With MingW on Windows, there's now a fairly straightforward process to > build your own on all platforms. Current changes are conservative, so > SVN tends to be as stable as the release versions. > > cheers > alex Thanks, For now, I can work around it pretty easily, so it's not worth the time it would take to install mingw and compile from SVN. Thanks anyway, Doug -- Posted via http://www.ruby-forum.com/. From niklas.baumstark at googlemail.com Fri Sep 12 13:25:14 2008 From: niklas.baumstark at googlemail.com (Niklas Baumstark) Date: Fri, 12 Sep 2008 19:25:14 +0200 Subject: [wxruby-users] embedding wxruby? Message-ID: <20080912192514.05c12eae@niklaspc> Hello, is it possible to code a wxWidgets GUI in C++ and pass the whole wxApp or just single windows to embedded Ruby code? This would be very nice to provide a scriptable plugin system. Greetings, Niklas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From alex at pressure.to Fri Sep 12 14:08:21 2008 From: alex at pressure.to (Alex Fenton) Date: Fri, 12 Sep 2008 19:08:21 +0100 Subject: [wxruby-users] alternative to destroying a dialog? (to avoid segfault) In-Reply-To: <887343af831ddf9b4c05075a272057e5@ruby-forum.com> References: <887343af831ddf9b4c05075a272057e5@ruby-forum.com> Message-ID: <48CAB015.8000405@pressure.to> Hi Doug Glidden wrote: > Hi, I'm running into a problem with a segfault when destroying a Dialog, > which I've read is a known problem that occurs when the GC cleans up > after a Dialog that contains a Sizer is destroyed (that's exactly my > situation). I don't get a segfault when I remove the destroy call, but > the app doesn't exit correctly, either--the process silently hangs. Is > there an alternative to destroy or something I can do to avoid the > segfault? It's shouldn't be a problem. Either: 1) Your app consists of one or more frames, with dialogs shown at various times for particular actions. This is the much commoner case. For this, the Dialogs should have the appropriate Frame parent as the first argument to the constructor, not nil. They'll then be cleaned up when the dialog is closed - no need to call destroy to exit cleanly. 2) Your app consists of a single dialog only (no frames etc). This is less usual but sometimes appropriate (eg, a simple long-running app accessed periodically from a TaskBarIcon). Then, the parent to the Dialog is nil. As long as the app is running, use hide() and show() to control the dialog's visibility. When it's time for the app to finish, call destroy() on the Dialog to end. If this doesn't help, please post a simple runnable demonstration of the problem and a bit more info about what you're trying to achieve. alex From rakaur at malkier.net Fri Sep 12 14:43:49 2008 From: rakaur at malkier.net (Eric Will) Date: Fri, 12 Sep 2008 14:43:49 -0400 Subject: [wxruby-users] evt_kill_focus Message-ID: <1ce38ef40809121143q3a7de380g123dee85a4bacf8@mail.gmail.com> Something's wacky with evt_kill_focus. It wasn't firing at all for me. It disallows passing a Wx id, and supposedly is a catch-all, but it was never firing. Latest WxRuby. I had to do this to fix it. No idea why this works or what's going on, just putting it out there: class MyListCtrl < Wx::ListCtrl def initialize(*args) super(*args) evt_kill_focus { } end end -------------- next part -------------- An HTML attachment was scrubbed... URL: From mario at ruby-im.net Fri Sep 12 20:13:02 2008 From: mario at ruby-im.net (Mario Steele) Date: Fri, 12 Sep 2008 19:13:02 -0500 Subject: [wxruby-users] embedding wxruby? In-Reply-To: <20080912192514.05c12eae@niklaspc> References: <20080912192514.05c12eae@niklaspc> Message-ID: Is it possible? Yes. How can you do it? I haven't a clue. Basically, you would need to wrap the widgets you want available on the Ruby Side, through the wxRuby controls, using the Swigified Wrappers to create the objects, and so forth. Sorry, it's not been a very much explored system, and I wouldn't have a clue in how to do it. On Fri, Sep 12, 2008 at 12:25 PM, Niklas Baumstark < niklas.baumstark at googlemail.com> wrote: > Hello, > > is it possible to code a wxWidgets GUI in C++ and pass the whole wxApp or > just single windows to embedded Ruby code? This would be very nice to > provide a scriptable plugin system. > > Greetings, > Niklas > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sat Sep 13 00:43:53 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Sat, 13 Sep 2008 06:43:53 +0200 Subject: [wxruby-users] alternative to destroying a dialog? (to avoid segfault) In-Reply-To: <48CAB015.8000405@pressure.to> References: <887343af831ddf9b4c05075a272057e5@ruby-forum.com> <48CAB015.8000405@pressure.to> Message-ID: <79923bfb5fb9d1305a2c95f52eea9341@ruby-forum.com> Alex Fenton wrote: > Hi [snip] > 1) Your app consists of one or more frames, with dialogs shown at > various times for particular actions. This is the much commoner case. > > For this, the Dialogs should have the appropriate Frame parent as the > first argument to the constructor, not nil. They'll then be cleaned up > when the dialog is closed - no need to call destroy to exit cleanly. > [snip] > > alex This is what I ended up doing. Actually, the dialog (a series of dialogs, actually) is displayed prior to the main window of the app being displayed. The way I originally had the app set up, I couldn't set the window to be the parent of the dialogs because it didn't exist yet, but I moved some things around so that the window can be the parent even though it hasn't been displayed yet. Thanks for the reply, Doug -- Posted via http://www.ruby-forum.com/. From niklas.baumstark at googlemail.com Sat Sep 13 06:42:32 2008 From: niklas.baumstark at googlemail.com (Niklas Baumstark) Date: Sat, 13 Sep 2008 12:42:32 +0200 Subject: [wxruby-users] embedding wxruby? In-Reply-To: References: <20080912192514.05c12eae@niklaspc> Message-ID: <20080913124232.7bc9e0a4@niklaspc> Hello, "Mario Steele" wrote: > Is it possible? Yes. How can you do it? I haven't a clue. Basically, you > would need to wrap the widgets you want available on the Ruby Side, through > the wxRuby controls, using the Swigified Wrappers to create the objects, and > so forth. > > Sorry, it's not been a very much explored system, and I wouldn't have a clue > in how to do it. OK, thanks for you answer. Maybe I'll dive a bit into it to try. Greetings, Niklas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From niklas.baumstark at googlemail.com Sun Sep 14 17:15:49 2008 From: niklas.baumstark at googlemail.com (Niklas Baumstark) Date: Sun, 14 Sep 2008 23:15:49 +0200 Subject: [wxruby-users] embedding wxruby? In-Reply-To: References: <20080912192514.05c12eae@niklaspc> Message-ID: <20080914231549.0df3b175@niklaspc> Hello, as announced, I played a bit around with swig and now seem to have found a first solution for my embedded ruby GUI plugin system. So far, I managed to wrap a C++ wxWindow object into a ruby Wx::Window object. I had to do a change to the wxRuby source to add a "wxWindow_to_ruby" function to the SWIG interface file for wxWindow (Window.i). Below is the (necessary?) code change and some example code based on the minimal.cpp, where i abused the about dialog to test my code. ===== SAMPLE START ===== ========================================================= Append to the bottom of "wxruby2/swig/classes/Window.i": ========================================================= %{ VALUE wxWindow_to_ruby(wxWindow* w) { return SWIG_NewPointerObj( (void *) w, SWIGTYPE_p_wxWindow, 0); } %} ============================================= My sample app (it's a modified minimal.cpp): ============================================= ... #include extern "C" void Init_wxruby2(); extern "C" void Init_wxWindow(); extern VALUE wxWindow_to_ruby(wxWindow* w); ... void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { ruby_init(); ruby_init_loadpath(); // the ruby file is in a sub-directory rb_eval_string(" $: << 'src' "); ruby_script("embed"); Init_wxruby2(); Init_wxWindow(); VALUE rubyWindow = wxWindow_to_ruby(this); cout << "Window in C++: " << rubyWindow << endl; rb_define_variable("$window", &rubyWindow); rb_require("ruby_test.rb"); ruby_finalize(); } ================== the ruby_test.rb: ================== if $0 != "embed" puts "WARNING: this script is supposed to be run only from 'embed'" exit end puts "Window in ruby: " + $window.inspect puts "Name of the window: " + $window.get_name ================== the output ================== Window in C++: 3019414920 Window in ruby: # Name of the window: frame ===== SAMPLE END ===== the linker has to be told to link to wxruby2.so, wxwidgets and ruby, of course. i share this because it may be of some use for someone. i think this seems fine for a first attempt, but * it is limited to be used with a wxWindow / Wx::Window and not at all generic. * the ruby script doesn't know about wxRuby. It just gets the raw Wx::Window object. it can't use $window.name instead of $window.get_name, for instance, and it can't access it's non-trivial members, because the corresponding types are not initialized. i didn't figure out a way to setup the whole wxRuby namespace in one rush (i would have to call every single Init_XY). the wx.rb could probably be included via rb_eval_string or something similiar for the sugar functionalities. didn't try it yet, however. * less important: the wxruby2.so has a size of 40MB. is it statically linked against wxWidgets? If so, can this easily be turned off? It would be great if someone has an idea on how to solve (some of) these problems. Greetings, Niklas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From alex at pressure.to Mon Sep 15 06:50:27 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 15 Sep 2008 11:50:27 +0100 Subject: [wxruby-users] embedding wxruby? In-Reply-To: <20080914231549.0df3b175@niklaspc> References: <20080912192514.05c12eae@niklaspc> <20080914231549.0df3b175@niklaspc> Message-ID: <48CE3DF3.7000100@pressure.to> Hi Niklas Niklas Baumstark wrote: > as announced, I played a bit around with swig and now seem to have found a first solution for my embedded ruby GUI plugin system. So far, I managed to wrap a C++ wxWindow object into a ruby Wx::Window object. > Broadly, I think you should be able to use almost all of the existing wxRuby SWIG etc codebase in an embedded setting. The main things that will need to change are the library initialisation code (in swig/wx.i) and the Wx::App initialisation code (in swig/classes/App.i) . You will in some way need to link the wx C++ App object to a ruby instance and make it a constant (like Wx::THE_APP in wxRuby). Having the App as a constant is the link that wxRuby uses to protect long-lived C++ objects like Windows from Ruby's garbage collection (see mark_wxApp). > ===== SAMPLE START ===== .... > * it is limited to be used with a wxWindow / Wx::Window and not at all generic. > Take a look at the function wxRuby_WrapWxObjectInRuby in swig/wx.i - this does exactly what you want. It uses wxWidgets type-information system to wrap a C++ object in the correct ruby class. It is applied to (almost) all methods in wxWidgets that return wxWindow* by a typemap. > * the ruby script doesn't know about wxRuby. It just gets the raw > Wx::Window object. it can't use $window.name instead of > $window.get_name, for instance, and it can't access it's non-trivial > members, because the corresponding types are not initialized. > i didn't figure out a way to setup the whole wxRuby namespace in one rush > (i would have to call every single Init_XY). SWIG's support for multi-module libraries is weak so wxRuby has to work around this by massaging the default generated code. The rake build system (in rake/rakewx.rb) appends a function called InitializeOtherModules to the generated file src/wx.cpp that initialises all the other modules, in alphabetic order. This is then called in Init_wxruby (in swig/wx.i). The other important thing is that each class should not be initialised before its parent class. The script swig/fixmodule.rb adds a line to each generated cpp file that calls Init_wx[PARENTCLASS] before proceeding with initialising self. > the wx.rb could probably be included via rb_eval_string or something > similiar for the sugar functionalities. didn't try it yet, however. > The ruby API function you want is rb_require. Some of the things in the ruby code are not just "sugar" but needed to make the classes work properly - eg GC helpers. > * less important: the wxruby2.so has a size of 40MB. is it statically > linked against wxWidgets? If so, can this easily be turned off? You could try strip -x to reduce the size. But SWIG adds a lot of overhead - the same runtime code is repeated and compiled for each SWIG class. I estimate that just getting round that would reduce the library size by about a third. On Linux and OS X at least - haven't tried with Windows - you can have a wxRuby that is dynamically linked. If you have a dynamic build available, either have wx-config point to it by default, or pass WXRUBY_DYNAMIC=1 as an environment variable to rake. Happy to help further but may be better to follow-up on the wxruby-dev list as this is fairly technical.... cheers alex From niklas.baumstark at googlemail.com Mon Sep 15 07:15:34 2008 From: niklas.baumstark at googlemail.com (Niklas Baumstark) Date: Mon, 15 Sep 2008 13:15:34 +0200 Subject: [wxruby-users] embedding wxruby? In-Reply-To: <48CE3DF3.7000100@pressure.to> References: <20080912192514.05c12eae@niklaspc> <20080914231549.0df3b175@niklaspc> <48CE3DF3.7000100@pressure.to> Message-ID: <20080915131534.08d66749@niklaspc> Hello, Alex Fenton wrote: > Hi Niklas > > Niklas Baumstark wrote: > > as announced, I played a bit around with swig and now seem to have found a first solution for my embedded ruby GUI plugin system. So far, I managed to wrap a C++ wxWindow object into a ruby Wx::Window object. > > > > Broadly, I think you should be able to use almost all of the existing > wxRuby SWIG etc codebase in an embedded setting. The main things that > will need to change are the library initialisation code (in swig/wx.i) > and the Wx::App initialisation code (in swig/classes/App.i) . > > You will in some way need to link the wx C++ App object to a ruby > instance and make it a constant (like Wx::THE_APP in wxRuby). Having the > App as a constant is the link that wxRuby uses to protect long-lived C++ > objects like Windows from Ruby's garbage collection (see mark_wxApp). OK, this is more sophisticated than i need it. i just need to wrap a wxPanel, because the main interface is managed by C++. > Take a look at the function wxRuby_WrapWxObjectInRuby in swig/wx.i - > this does exactly what you want. It uses wxWidgets type-information > system to wrap a C++ object in the correct ruby class. > It is applied to (almost) all methods in wxWidgets that return wxWindow* > by a typemap. oh, very nice, this function is what i was searching for :) by mario's answer i guessed it would not exist so i tried to write one by myself. > > * the ruby script doesn't know about wxRuby. It just gets the raw > > Wx::Window object. it can't use $window.name instead of > > $window.get_name, for instance, and it can't access it's non-trivial > > members, because the corresponding types are not initialized. > > i didn't figure out a way to setup the whole wxRuby namespace in one rush > > (i would have to call every single Init_XY). > > SWIG's support for multi-module libraries is weak so wxRuby has to work > around this by massaging the default generated code. > > The rake build system (in rake/rakewx.rb) appends a function called > InitializeOtherModules to the generated file src/wx.cpp that initialises > all the other modules, in alphabetic order. This is then called in > Init_wxruby (in swig/wx.i). OK good to know. > The other important thing is that each class should not be initialised > before its parent class. The script swig/fixmodule.rb adds a line to > each generated cpp file that calls Init_wx[PARENTCLASS] before > proceeding with initialising self. i discovered this already. > > the wx.rb could probably be included via rb_eval_string or something > > similiar for the sugar functionalities. didn't try it yet, however. > > > The ruby API function you want is rb_require. Some of the things in the > ruby code are not just "sugar" but needed to make the classes work > properly - eg GC helpers. another one good to know. > > * less important: the wxruby2.so has a size of 40MB. is it statically > > linked against wxWidgets? If so, can this easily be turned off? > > You could try strip -x to reduce the size. But SWIG adds a lot of > overhead - the same runtime code is repeated and compiled for each SWIG > class. I estimate that just getting round that would reduce the library > size by about a third. > > On Linux and OS X at least - haven't tried with Windows - you can have a > wxRuby that is dynamically linked. If you have a dynamic build > available, either have wx-config point to it by default, or pass > WXRUBY_DYNAMIC=1 as an environment variable to rake. I'll try this. thank you very much! > Happy to help further but may be better to follow-up on the wxruby-dev > list as this is fairly technical.... I would like to, but i can't subscribe to it properly. It says 403 when i want to confirm the subscription :( at least it did yesterday. Greetings, Niklas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From alex at pressure.to Mon Sep 15 07:40:53 2008 From: alex at pressure.to (Alex Fenton) Date: Mon, 15 Sep 2008 12:40:53 +0100 Subject: [wxruby-users] embedding wxruby? In-Reply-To: <20080915131534.08d66749@niklaspc> References: <20080912192514.05c12eae@niklaspc> <20080914231549.0df3b175@niklaspc> <48CE3DF3.7000100@pressure.to> <20080915131534.08d66749@niklaspc> Message-ID: <48CE49C5.6000306@pressure.to> Niklas Baumstark wrote: >> >> You will in some way need to link the wx C++ App object to a ruby >> instance and make it a constant (like Wx::THE_APP in wxRuby). Having the >> App as a constant is the link that wxRuby uses to protect long-lived C++ >> objects like Windows from Ruby's garbage collection (see mark_wxApp). >> > > OK, this is more sophisticated than i need it. i just need to wrap a wxPanel, because the main interface is managed by C++. > OK, but to avoid leaks, or crashes from prematurely deleted objects, you will need some sort of memory management strategy. It gets quite complicated but most of the work is done ;) >> Happy to help further but may be better to follow-up on the wxruby-dev >> list as this is fairly technical.... >> > > I would like to, but i can't subscribe to it properly. It says 403 when i want to confirm the subscription :( at least it did yesterday. > Just tried it and it seems to be working. If clicking on the link from the email make sure the URL isn't truncated as it contains an authentication string. alex From niklas.baumstark at googlemail.com Mon Sep 15 08:02:26 2008 From: niklas.baumstark at googlemail.com (Niklas Baumstark) Date: Mon, 15 Sep 2008 14:02:26 +0200 Subject: [wxruby-users] embedding wxruby? In-Reply-To: <48CE49C5.6000306@pressure.to> References: <20080912192514.05c12eae@niklaspc> <20080914231549.0df3b175@niklaspc> <48CE3DF3.7000100@pressure.to> <20080915131534.08d66749@niklaspc> <48CE49C5.6000306@pressure.to> Message-ID: <20080915140226.4d06a2eb@niklaspc> Hello, Alex Fenton wrote: > Niklas Baumstark wrote: > >> > >> You will in some way need to link the wx C++ App object to a ruby > >> instance and make it a constant (like Wx::THE_APP in wxRuby). Having the > >> App as a constant is the link that wxRuby uses to protect long-lived C++ > >> objects like Windows from Ruby's garbage collection (see mark_wxApp). > >> > > > > OK, this is more sophisticated than i need it. i just need to wrap a wxPanel, because the main interface is managed by C++. > > > > OK, but to avoid leaks, or crashes from prematurely deleted objects, you > will need some sort of memory management strategy. It gets quite > complicated but most of the work is done ;) I'll try to. thank you for the information. > >> Happy to help further but may be better to follow-up on the wxruby-dev > >> list as this is fairly technical.... > >> > > > > I would like to, but i can't subscribe to it properly. It says 403 when i want to confirm the subscription :( at least it did yesterday. > > > > Just tried it and it seems to be working. If clicking on the link from > the email make sure the URL isn't truncated as it contains an > authentication string. Yeah it's working now. I will ask future questions on this subjects on the dev mailing list. Greetings, Niklas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available URL: From lists at ruby-forum.com Mon Sep 15 11:33:00 2008 From: lists at ruby-forum.com (Richard White) Date: Mon, 15 Sep 2008 17:33:00 +0200 Subject: [wxruby-users] require fails with undefined symbol In-Reply-To: References: Message-ID: <96d260e8960000d28558bc3f0540238c@ruby-forum.com> Upgrading to Ubuntu 8.04 has cured the problem! -- Posted via http://www.ruby-forum.com/. From fabio.petrucci at gmail.com Mon Sep 15 14:32:09 2008 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Mon, 15 Sep 2008 20:32:09 +0200 Subject: [wxruby-users] load_panel_subclass help Message-ID: Hi all, i'm having several problems using 'load_panel_subclass' function. The way i suppose to use it is in main_frame.rb on attached file but i get an arror. could somebody tell me how to use it? I'm working on win xp sp2 ruby 1.8.6 patchlevel 111 wxruby 1.9.8 wx_sugar 0.1.20 thank you all. Fabio. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.zip Type: application/zip Size: 4466 bytes Desc: not available URL: From rene at so36.net Mon Sep 15 19:50:14 2008 From: rene at so36.net (Rene Paulokat) Date: Tue, 16 Sep 2008 01:50:14 +0200 Subject: [wxruby-users] wxruby - compile trouble on 64bit linux (ubuntu) Message-ID: <20080916015014.3de0746d@tank> hi, i'd like to give an report how i managed to get wxruby-1.9.8 installed on ubuntu 8.04. think this could be usefull for others. after several errors during wxruby compilation i decided to get rid of wxwidgets-libs and swig that came with / were installed via ubuntu-packet-manager. i got ahold of the mentioned versions of swig and wxwidgets and installed them from source. but this did NOT change the error (something with AboutDialog.o and unreferenced Symbol). what did the trick for me finally was to change wxruby-1.9.8/rake/rakeconfigure.rb and add there some "-fPIC" to --- snip --- # Flags to be passed to the C++ compiler $cppflags = [ $wx_cppflags, $ruby_cppflags, $extra_cppflags, $ruby_includes , "-fPIC"].join(' ') # Flags to be passed to the linker $ldflags = [ $ruby_ldflags, $extra_ldflags, "-fPIC" ].join(' ') --- snap --- did not find another solution to pass this arguments when invoking rake... big thanks to the ppl working on development of wxruby. regards rene From lists at ruby-forum.com Mon Sep 15 20:21:52 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Tue, 16 Sep 2008 02:21:52 +0200 Subject: [wxruby-users] argument type error in StyledTextControl 'LineFromPosition' Message-ID: <5331fe5dcf10541fcad8c9665fdacb4e@ruby-forum.com> I got the following error when I was randomly clicking margins and lines in a StyledTextControl (3 margins). It doesn't occur often, usually happens after many clicks (20 or so). Expected argument 1 of type int, but got Wxruby2::Point # in SWIG method 'LineFromPosition' My env: wxRuby mingw32 1.9.8, ruby 1.8.6 p287 on XP Regards, Zhimin -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Tue Sep 16 08:28:01 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 16 Sep 2008 13:28:01 +0100 Subject: [wxruby-users] load_panel_subclass help In-Reply-To: References: Message-ID: <48CFA651.4010300@pressure.to> Fabio Petrucci wrote: > i'm having several problems using 'load_panel_subclass' function. > > The way i suppose to use it is in main_frame.rb on attached file but i > get an arror. > > could somebody tell me how to use it? You don't need to use load_panel_subclass here at all - calling it is an error. The 'CONTATTI' panel is already part of the overall layout of the frame and so is loaded anyway when the whole frame is loaded. load_panel_subclass is only used for when you have a top-level panel (ie, no parent) defined in your XRC file, and want to load that panel as the child of an arbitrary window. hth alex From fabio.petrucci at gmail.com Tue Sep 16 09:13:48 2008 From: fabio.petrucci at gmail.com (Fabio Petrucci) Date: Tue, 16 Sep 2008 15:13:48 +0200 Subject: [wxruby-users] load_panel_subclass help In-Reply-To: <48CFA651.4010300@pressure.to> References: <48CFA651.4010300@pressure.to> Message-ID: Thank you Alex, the problem is related on code organization: The xrc file consist of 1 frame and, inside it, a notebook with 2 folders (panels). Conceptually they are separated objects with their own code and logic. What i need is to separate these entities into their own class for better code organization avoiding to encapsulate them into a external custom proxy class: that's the reason i used 'load_panel_subclass'. cheers fabio. On Tue, Sep 16, 2008 at 2:28 PM, Alex Fenton wrote: > Fabio Petrucci wrote: > >> i'm having several problems using 'load_panel_subclass' function. >> >> The way i suppose to use it is in main_frame.rb on attached file but i get >> an arror. >> >> could somebody tell me how to use it? >> > > You don't need to use load_panel_subclass here at all - calling it is an > error. The 'CONTATTI' panel is already part of the overall layout of the > frame and so is loaded anyway when the whole frame is loaded. > > load_panel_subclass is only used for when you have a top-level panel (ie, > no parent) defined in your XRC file, and want to load that panel as the > child of an arbitrary window. > > hth > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Tue Sep 16 10:30:18 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 16 Sep 2008 15:30:18 +0100 Subject: [wxruby-users] wxruby - compile trouble on 64bit linux (ubuntu) In-Reply-To: <20080916015014.3de0746d@tank> References: <20080916015014.3de0746d@tank> Message-ID: <48CFC2FA.4080204@pressure.to> Hi Rene Rene Paulokat wrote: > after several errors during wxruby compilation i decided to get rid of wxwidgets-libs and swig that came with / were installed via ubuntu-packet-manager. > i got ahold of the mentioned versions of swig and wxwidgets and installed them from source. > > but this did NOT change the error (something with AboutDialog.o and unreferenced Symbol). > > what did the trick for me finally was to change wxruby-1.9.8/rake/rakeconfigure.rb and add there some "-fPIC" to > > --- snip --- > # Flags to be passed to the C++ compiler > $cppflags = [ $wx_cppflags, $ruby_cppflags, > $extra_cppflags, $ruby_includes , "-fPIC"].join(' ') > > # Flags to be passed to the linker > $ldflags = [ $ruby_ldflags, $extra_ldflags, "-fPIC" ].join(' ') > > --- snap --- > Thanks for taking the time to write in about this. It's mentioned on the wiki here: http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets but I agree we should make that easier to find. I plan to write an INSTALL.txt to go with the source tar.gz which covers this sort of thing. > did not find another solution to pass this arguments when invoking rake... > wxRuby gets its flags and options to pass to the C compiler from wxWidgets and Ruby, I think if wxWidgets is built with -fPIC, so will wxRuby, without having to change the rakefile. Were you building against a static or dynamic wxWidgets? > big thanks to the ppl working on development of wxruby. > thanks Alex From alex at pressure.to Tue Sep 16 10:58:52 2008 From: alex at pressure.to (Alex Fenton) Date: Tue, 16 Sep 2008 15:58:52 +0100 Subject: [wxruby-users] argument type error in StyledTextControl 'LineFromPosition' In-Reply-To: <5331fe5dcf10541fcad8c9665fdacb4e@ruby-forum.com> References: <5331fe5dcf10541fcad8c9665fdacb4e@ruby-forum.com> Message-ID: <48CFC9AC.1080100@pressure.to> Zhimin Zhan wrote: > I got the following error when I was randomly clicking margins and lines > in a StyledTextControl (3 margins). It doesn't occur often, usually > happens after many clicks (20 or so). > > Expected argument 1 of type int, but got Wxruby2::Point # (1753743404, 0)> > in SWIG method 'LineFromPosition' > Thanks for the report. I can reproduce this issue but I don't know why it is happening. I've filed it as a bug for fixing: http://rubyforge.org/tracker/?func=detail&atid=218&aid=21985&group_id=35 cheers alex From mario at ruby-im.net Tue Sep 16 22:55:03 2008 From: mario at ruby-im.net (Mario Steele) Date: Tue, 16 Sep 2008 21:55:03 -0500 Subject: [wxruby-users] wxruby - compile trouble on 64bit linux (ubuntu) In-Reply-To: <48CFC2FA.4080204@pressure.to> References: <20080916015014.3de0746d@tank> <48CFC2FA.4080204@pressure.to> Message-ID: Actually Alex, wxRuby's build process won't receive from wx-config, or ruby.h, I had to do the same hack myself when I did the x86 build of wxRuby gem. No matter what I tried, I couldn't get -fPIC in there, and I tried everything. On Tue, Sep 16, 2008 at 9:30 AM, Alex Fenton wrote: > Hi Rene > > Rene Paulokat wrote: > >> after several errors during wxruby compilation i decided to get rid of >> wxwidgets-libs and swig that came with / were installed via >> ubuntu-packet-manager. i got ahold of the mentioned versions of swig and >> wxwidgets and installed them from source. >> >> but this did NOT change the error (something with AboutDialog.o and >> unreferenced Symbol). >> >> what did the trick for me finally was to change >> wxruby-1.9.8/rake/rakeconfigure.rb and add there some "-fPIC" to >> --- snip --- # Flags to be passed to the C++ compiler >> $cppflags = [ $wx_cppflags, $ruby_cppflags, $extra_cppflags, >> $ruby_includes , "-fPIC"].join(' ') >> >> # Flags to be passed to the linker >> $ldflags = [ $ruby_ldflags, $extra_ldflags, "-fPIC" ].join(' ') >> >> --- snap --- >> >> > > Thanks for taking the time to write in about this. It's mentioned on the > wiki here: > > http://wxruby.rubyforge.org/wiki/wiki.pl?HowToBuildWxWidgets > > but I agree we should make that easier to find. I plan to write an > INSTALL.txt to go with the source tar.gz which covers this sort of thing. > > did not find another solution to pass this arguments when invoking rake... >> >> > > wxRuby gets its flags and options to pass to the C compiler from wxWidgets > and Ruby, I think if wxWidgets is built with -fPIC, so will wxRuby, without > having to change the rakefile. > > Were you building against a static or dynamic wxWidgets? > > big thanks to the ppl working on development of wxruby. >> >> > > thanks > Alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Sep 17 02:53:13 2008 From: lists at ruby-forum.com (Zhimin Zhan) Date: Wed, 17 Sep 2008 08:53:13 +0200 Subject: [wxruby-users] argument type error in StyledTextControl 'LineFromPosition' In-Reply-To: <5331fe5dcf10541fcad8c9665fdacb4e@ruby-forum.com> References: <5331fe5dcf10541fcad8c9665fdacb4e@ruby-forum.com> Message-ID: <42f180c0d7a9f225971d17d6c86521c1@ruby-forum.com> Hi Alex, The problem happens only on mingw32 build. I tried 1.9.8 mswin gem, it's fine. Regards, Zhimin -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Sep 17 03:10:10 2008 From: lists at ruby-forum.com (Daniel King) Date: Wed, 17 Sep 2008 09:10:10 +0200 Subject: [wxruby-users] Where is Wx::Execute? Message-ID: <0bb34e0f2acd7716dbdd14aba18f5c08@ruby-forum.com> wxExecute is in wxwidgets. but where is Wx::Execute? How can I execute a command in the operating system? -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Wed Sep 17 03:45:50 2008 From: mario at ruby-im.net (Mario Steele) Date: Wed, 17 Sep 2008 02:45:50 -0500 Subject: [wxruby-users] Where is Wx::Execute? In-Reply-To: <0bb34e0f2acd7716dbdd14aba18f5c08@ruby-forum.com> References: <0bb34e0f2acd7716dbdd14aba18f5c08@ruby-forum.com> Message-ID: wxRuby doesn't implement wxExecute, or any of the similar functions, since Ruby has it's own way of doing it. You would need to use Kernel::system() Or Kerne::`` These execute sub-commands. If you need Input/Output Capture, look into Open3/Open4. On Wed, Sep 17, 2008 at 2:10 AM, Daniel King wrote: > wxExecute is in wxwidgets. but where is Wx::Execute? > How can I execute a command in the operating system? > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Wed Sep 17 06:55:10 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 17 Sep 2008 11:55:10 +0100 Subject: [wxruby-users] load_panel_subclass help Message-ID: <48D0E20E.4030001@pressure.to> Fabio > the problem is related on code organization: > > The xrc file consist of 1 frame and, inside it, a notebook with 2 > folders > (panels). > Conceptually they are separated objects with their own code and logic. > > What i need is to separate these entities into their own class for > better > code organization avoiding to encapsulate them into a external custom > proxy > class: that's the reason i used 'load_panel_subclass' Use Ruby Modules instead of Classes to encapsulate the behaviour of the inner windows, such as your Panel. After the layout has been loaded from XRC, retrieve the panel, and use something like panel.extend(MyPanelBehaviours) To add the logic to it. If needed, you can use Module.extended to do initialize- like work in setting up the Panel. By the way, XRCise will do this automatically for you, if you name your inner windows. hth alex From rene at so36.net Wed Sep 17 07:50:43 2008 From: rene at so36.net (rene paulokat) Date: Wed, 17 Sep 2008 13:50:43 +0200 Subject: [wxruby-users] wxruby - compile trouble on 64bit linux (ubuntu) In-Reply-To: References: <20080916015014.3de0746d@tank> <48CFC2FA.4080204@pressure.to> Message-ID: Am 17.09.2008 um 04:55 schrieb Mario Steele: > Actually Alex, > > wxRuby's build process won't receive from wx-config, or ruby.h, I > had to do the same hack myself when I did the x86 build of wxRuby > gem. No matter what I tried, I couldn't get -fPIC in there, and I > tried everything. reproduceable - i recompiled wxwidgets explicitely with '-fPIC', but compilation of wxruby failed nevertheless. - until the mentioned changes were made to rakeconfigure.rb rene __ take care not to get sucked into /dev/null ! From erubin at valcom.com Wed Sep 17 09:48:08 2008 From: erubin at valcom.com (Eric Rubin) Date: Wed, 17 Sep 2008 09:48:08 -0400 Subject: [wxruby-users] Disabling the TextCtrl part of a SpinCtrl In-Reply-To: Message-ID: <3F2CAE8790DC419AA373376E341E16A5@valcom.com> How can I get to the TextCtrl part of a SpinCtrl? If I call disable on the SpinCtrl it disables the arrows, but not the TextCtrl (under Windows XP). How can I disable the TextCtrl part? Eric Rubin From alex at pressure.to Thu Sep 18 06:09:50 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 18 Sep 2008 11:09:50 +0100 Subject: [wxruby-users] Disabling the TextCtrl part of a SpinCtrl In-Reply-To: <3F2CAE8790DC419AA373376E341E16A5@valcom.com> References: <3F2CAE8790DC419AA373376E341E16A5@valcom.com> Message-ID: <48D228EE.8010900@pressure.to> Eric Rubin wrote: > How can I get to the TextCtrl part of a SpinCtrl? If I call disable on the > SpinCtrl it disables the arrows, but not the TextCtrl (under Windows XP). > How can I disable the TextCtrl part? > I'm not really sure - at the moment, I can't seem to get the TextCtrl to accept input in a simple SpinCtrl. Do you have a sample programme you could show? This question seems to have come up on the wxWidgets / wxPython list but I can't find a definitive answer. You could try searching those further by looking for wxSpinCtrl etc alex From lists at ruby-forum.com Thu Sep 18 08:43:19 2008 From: lists at ruby-forum.com (Doug Glidden) Date: Thu, 18 Sep 2008 14:43:19 +0200 Subject: [wxruby-users] TAB_TRAVERSAL within a dialog box Message-ID: <57f3f07decc5e842ceac63c086ea8d47@ruby-forum.com> Hi, Is there any known issue with using a Panel with TAB_TRAVERSAL within a Dialog? I'm having an issue my app freezing up when I enable the TAB_TRAVERSAL style on a panel within a dialog box, and before I go through the trouble of making a simpler demo that will show what's happening, I wanted to make sure that there's not a known issue here. If so, is there a workaround? The problem doesn't show up until I click on one of several radio buttons that are outside of the Panel with the TAB_TRAVERSAL flag set. Then the app immediately freezes, without even calling the event handler for the radio button. Doug -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Thu Sep 18 08:56:26 2008 From: alex at pressure.to (Alex Fenton) Date: Thu, 18 Sep 2008 13:56:26 +0100 Subject: [wxruby-users] TAB_TRAVERSAL within a dialog box In-Reply-To: <57f3f07decc5e842ceac63c086ea8d47@ruby-forum.com> References: <57f3f07decc5e842ceac63c086ea8d47@ruby-forum.com> Message-ID: <48D24FFA.6020502@pressure.to> Doug Glidden wrote: > Is there any known issue with using a Panel with TAB_TRAVERSAL within a > Dialog? I'm having an issue my app freezing up when I enable the > TAB_TRAVERSAL style on a panel within a dialog box, and before I go > through the trouble of making a simpler demo that will show what's > happening, I wanted to make sure that there's not a known issue here. > If so, is there a workaround? There's no known issue, but if you'd care to send in a short, complete sample that demonstrates the problem, I'd be very happy to have a look. I don't know if this wxWidgets issue may be related: http://lists.wxwidgets.org/pipermail/wx-users/2006-October/094471.html alex From lists at ruby-forum.com Tue Sep 23 22:55:29 2008 From: lists at ruby-forum.com (Nathan Macinnes) Date: Wed, 24 Sep 2008 04:55:29 +0200 Subject: [wxruby-users] sample desktop app Message-ID: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> Hi all, I'm trying to develop a desktop application, and since I've done a fair bit of work with RoR before, I figured ruby is a good way to go about it. My application will be largely database driven. I'm looking for a sample desktop application which I can learn a few things from. Obviously the less restrictive the license the better, and it'd also be good if I can find one which is database driven. Google seems to provide very little.. or at least, the results are cluttered by RoR things. I was wondering if anyone in the group knows of any. Nathan -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Sep 24 02:57:21 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 24 Sep 2008 07:57:21 +0100 Subject: [wxruby-users] sample desktop app In-Reply-To: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> References: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> Message-ID: <48D9E4D1.1070900@pressure.to> Hi Nathan Nathan Macinnes wrote: > I'm trying to develop a desktop application, and since I've done a fair > bit of work with RoR before, I figured ruby is a good way to go about > it. My application will be largely database driven. > I'm looking for a sample desktop application which I can learn a few > things from. Obviously the less restrictive the license the better, and > it'd also be good if I can find one which is database driven. Google > seems to provide very little.. or at least, the results are cluttered by > RoR things. I was wondering if anyone in the group knows of any. There's a list of some wxRuby applications on the wiki: http://wxruby.rubyforge.org/wiki/wiki.pl?OnlineCodeExamples Of those, Weft QDA is a database (SQLite) backed application, and has a public domain licence. http://rubyforge.org/projects/weft-qda/ It uses its own ActiveRecord-like persistence layer, with an Observer pattern to update the relevant GUI elements as changes to the database are saved. I'd recommend you look at the code in Subversion as its a better model for designing database apps. A disadvantage for study purposes is that its a relatively complex app - > 15k lines of ruby code, with a schema running to several hundred lines using triggers and views: http://weft-qda.rubyforge.org/svn/trunk/weft-qda/share/schema.sql A simpler example to look at might be Ruby SQLite GUI, which is a desktop browser for SQLite databases: http://rsqlitegui.rubyforge.org/ It uses Ruby-GTK2, rather than wxRuby. GTK2 is another good GUI library, long established and with a wide range of widgets. However IMHO it works considerably less well on Windows and OS X than it does on Linux, whereas wxRuby is equally good on all three. hth alex From johnnyk3 at gmail.com Wed Sep 24 09:43:53 2008 From: johnnyk3 at gmail.com (John Kennedy) Date: Wed, 24 Sep 2008 09:43:53 -0400 Subject: [wxruby-users] sample desktop app In-Reply-To: <48D9E4D1.1070900@pressure.to> References: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> <48D9E4D1.1070900@pressure.to> Message-ID: Just be sure to organize your code from the beginning. It's too easy to write spaghetti code in a scripting language. Stick with your MVC roots. It's useful with any kind of application development, not just the web. But also, don't try to mimic rails, there's a lot of ways to implement MVC, not just the way rails does. -jk On Wed, Sep 24, 2008 at 2:57 AM, Alex Fenton wrote: > Hi Nathan > > Nathan Macinnes wrote: > >> I'm trying to develop a desktop application, and since I've done a fair >> bit of work with RoR before, I figured ruby is a good way to go about >> it. My application will be largely database driven. >> I'm looking for a sample desktop application which I can learn a few >> things from. Obviously the less restrictive the license the better, and >> it'd also be good if I can find one which is database driven. Google >> seems to provide very little.. or at least, the results are cluttered by >> RoR things. I was wondering if anyone in the group knows of any. >> > There's a list of some wxRuby applications on the wiki: > http://wxruby.rubyforge.org/wiki/wiki.pl?OnlineCodeExamples > > Of those, Weft QDA is a database (SQLite) backed application, and has a > public domain licence. > http://rubyforge.org/projects/weft-qda/ > > It uses its own ActiveRecord-like persistence layer, with an Observer > pattern to update the relevant GUI elements as changes to the database are > saved. I'd recommend you look at the code in Subversion as its a better > model for designing database apps. > > A disadvantage for study purposes is that its a relatively complex app - > > 15k lines of ruby code, with a schema running to several hundred lines using > triggers and views: > http://weft-qda.rubyforge.org/svn/trunk/weft-qda/share/schema.sql > > A simpler example to look at might be Ruby SQLite GUI, which is a desktop > browser for SQLite databases: > http://rsqlitegui.rubyforge.org/ > > It uses Ruby-GTK2, rather than wxRuby. GTK2 is another good GUI library, > long established and with a wide range of widgets. However IMHO it works > considerably less well on Windows and OS X than it does on Linux, whereas > wxRuby is equally good on all three. > > hth > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Sep 24 10:54:31 2008 From: lists at ruby-forum.com (Nathan Macinnes) Date: Wed, 24 Sep 2008 16:54:31 +0200 Subject: [wxruby-users] sample desktop app In-Reply-To: References: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> <48D9E4D1.1070900@pressure.to> Message-ID: <99ca5cc775d1ff45205b4d85794493a9@ruby-forum.com> Thanks for the help guys. Weft looks like a good option for me to use... and because it's public domain, I can even use the code without any worries. The Ruby SQLite GUI is a bit easier for me to get my head around, but at the same time, the code isn't as well organised... I suppose for a smaller project it doesn't matter so much. And you're right about the Ruby-GTK2 point... I'd already decided I want to use wxWidgets because I use Linux but most of my target audience use Windows... and it wouldn't hurt to make it work for Macs too. John, thanks for the heads-up. I do plan on sticking to MVC as much as possible... I'm not quite sure what that looks like yet though. -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Wed Sep 24 18:57:25 2008 From: alex at pressure.to (Alex Fenton) Date: Wed, 24 Sep 2008 23:57:25 +0100 Subject: [wxruby-users] sample desktop app In-Reply-To: <99ca5cc775d1ff45205b4d85794493a9@ruby-forum.com> References: <6045a8f006e617d0f3c3d46743f2f52b@ruby-forum.com> <48D9E4D1.1070900@pressure.to> <99ca5cc775d1ff45205b4d85794493a9@ruby-forum.com> Message-ID: <48DAC5D5.3080805@pressure.to> Nathan Macinnes wrote: > John, thanks for the heads-up. I do plan on sticking to MVC as much as > possible... I'm not quite sure what that looks like yet though. > I think John's advice was sound. I've never sat down and read a book about MVC and I'm not a professionaly programmer, though in a previous life I did a lot of web programming in Perl. But I can say what enabled Weft QDA to go from a specialised and limited program to something to which its now quite extensible - I mean, that I can add quite radical new features to without breaking lots of stuff. It probably roughly fits an MVC model... M: your non-GUI classes stand alone and can be unit-tested. So you know that the objects you're going to display (in Weft, Documents, Categories, Text Fragments, etc) can be created, changed, saved and restored without problems. This means you don't waste time clicking round in a GUI to fix issues with databases or how they translate to ruby classes. V: Your GUI code is strictly separate - in Weft, it's all in a wxgui directory. All the GUI code deals with layout (whether that's through XRC, some kind of sugary syntax, or bog-standard wxRuby code - Weft uses all three) and event handling. The sort of logic that deals with saving non-GUI objects, and updating related objects should be outside the GUI code. So you say: def on_click_ok document.title = gui_text_box.value document.save rescue BadDocumentTitleError display_gui_error_message "The title was invalid" end The validation, and the mechanics of how the object is saved are hidden from the GUI code. It just has to know how to deal with errors. The biggest jump for Weft was separating the GUI code that made changes to objects, from the GUI code that updates the state of objects. Otherwise every place that changes a database object has to know about every place that that object might be displayed. This quickly becomes impossible, and you get endless problems with stale/inconsistent object data being presented to the user. One way of tackling this is to use Observer: when an object is saved, all interested GUI representations are informed and deal with the new state of the object (eg a new title) accordingly. Another is using wxRuby's UpdateUIEvent - this is handy when, for example, you want menu items to be enabled or disabled based on a criterion, but don't want to have to keep track of that every time it changes, just when the relevant menu item is displayed. So, if you want a "Save" menu item that is only active when there are unsaved changes in a model object called document, you can do something like evt_update_ui(Wx::ID_SAVE) { | e | e.enable(true) if document.has_unsaved_changes } hth alex From lists at ruby-forum.com Fri Sep 26 20:03:34 2008 From: lists at ruby-forum.com (Omar Hernandez) Date: Sat, 27 Sep 2008 02:03:34 +0200 Subject: [wxruby-users] Problems with ToolBar Sintaxis Message-ID: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> First of all, it's my first week learnig ruby and so is for wxruby,also this is my first time working with a GUI so please, please, be patient. I'm having problems with the code for a toolbar, i want to add an item, but a don't know how. this is my code for now: @toolBarPrincipal=ToolBar.new(@panel) @toolBarPrincipal.add_tool(-1, '&Bonzai', Bitmap.new("/home/....... icon.ico")) I've already red the http://wxruby.rubyforge.org/doc/toolbar.html page (mi code is basically what comes there. I want to put it into a panel, named panel. At this point, a litle dot is drawn on the top-left corner (under a menu bar) but no icon. I'd appreciate if you help me. A correction, some code examples or some links would be perfect. Thanks!! Sorry if i'm making a thread that already exists (i searched first) -- Posted via http://www.ruby-forum.com/. From mario at ruby-im.net Sat Sep 27 07:07:01 2008 From: mario at ruby-im.net (Mario Steele) Date: Sat, 27 Sep 2008 06:07:01 -0500 Subject: [wxruby-users] Problems with ToolBar Sintaxis In-Reply-To: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> References: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> Message-ID: What's going on, is that the Toolbar is not resizing, so you need to either resize the toolbar yourself, or you need to use Wx::BoxSizer. Personally, Wx::BoxSizer is easier to do. Simply do the following: box = Wx::BoxSizer.new(Wx::HORIZONTAL) box.add(@toolBarPrincipal,1,Wx::ALL) @panel.set_sizer(box) This will allow the Toolbar to expand to take up as much space as possible, least you put in another control with the Toolbar itself (Not the Toolbar Item) Hope this helps. On Fri, Sep 26, 2008 at 7:03 PM, Omar Hernandez wrote: > First of all, it's my first week learnig ruby and so is for wxruby,also > this is my first time working with a GUI so please, please, be patient. > > I'm having problems with the code for a toolbar, i want to add an item, > but a don't know how. this is my code for now: > > > @toolBarPrincipal=ToolBar.new(@panel) > @toolBarPrincipal.add_tool(-1, '&Bonzai', Bitmap.new("/home/....... > icon.ico")) > > I've already red the http://wxruby.rubyforge.org/doc/toolbar.html page > (mi code is basically what comes there. > > I want to put it into a panel, named panel. At this point, a litle dot > is drawn on the top-left corner (under a menu bar) but no icon. > > I'd appreciate if you help me. A correction, some code examples or some > links would be perfect. > > > Thanks!! > > Sorry if i'm making a thread that already exists (i searched first) > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at pressure.to Sat Sep 27 07:09:19 2008 From: alex at pressure.to (Alex Fenton) Date: Sat, 27 Sep 2008 12:09:19 +0100 Subject: [wxruby-users] Problems with ToolBar Sintaxis In-Reply-To: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> References: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> Message-ID: <48DE145F.4090104@pressure.to> Hi Omar Hernandez wrote: > I'm having problems with the code for a toolbar, i want to add an item, > but a don't know how. this is my code for now: > > > @toolBarPrincipal=ToolBar.new(@panel) > @toolBarPrincipal.add_tool(-1, '&Bonzai', Bitmap.new("/home/....... > icon.ico")) > > I've already red the http://wxruby.rubyforge.org/doc/toolbar.html page > (mi code is basically what comes there. > > I want to put it into a panel, named panel. At this point, a litle dot > is drawn on the top-left corner (under a menu bar) but no icon. > Maybe you need to call ToolBar#realize after you've added all your items? Or if you are placing the ToolBar within a panel, maybe you need to use a Sizer to allocate space for the ToolBar? If the ToolBar is intended as the main ToolBar for a frame, it can be better to call Frame#create_tool_bar or Frame#set_tool_bar. This will deal with the sizing, and also ensure that the ToolBar has a native style - on OS X, a native toolbar can only be on the top. > I'd appreciate if you help me. A correction, some code examples or some > links would be perfect. You might take a look at the wxToolBar.rb sample in samples/bigdemo/; you should find the sampes installed in your gems directory. If you want further help, please post a short, complete, runnable sample with your toolbar code. hth alex From lists at ruby-forum.com Mon Sep 29 15:49:09 2008 From: lists at ruby-forum.com (Omar Hernandez) Date: Mon, 29 Sep 2008 21:49:09 +0200 Subject: [wxruby-users] Problems with ToolBar Sintaxis In-Reply-To: <48DE145F.4090104@pressure.to> References: <973c7cae03b14df2b5d1d9b4d89ed7fb@ruby-forum.com> <48DE145F.4090104@pressure.to> Message-ID: <22f14ca344e9312f3dad0e15f000d47b@ruby-forum.com> Thank you they both (Mario Steele's and Alex Fenton's) worked. It is a main toolbar, is like the file_new, file_open toolbars of most programs so I ended up using the Frame#create_tool_bar method and I checked the sample: wxToolBar.rb in samples/bigdemo/ in the gems directory see ya. -- Posted via http://www.ruby-forum.com/.