From Philip.Schalm at nic.bc.ca Fri Mar 16 13:39:48 2007 From: Philip.Schalm at nic.bc.ca (Philip Schalm) Date: Fri, 16 Mar 2007 10:39:48 -0700 Subject: [Wxruby-users] General segfaulting Message-ID: <2E853F7E065E754594F0B57044123C3402AA6DB9@cvcnt7.nic.bc.ca> I'm having issues with WxRuby segfaulting when it's dealing with external data in one form or another. I can reliably force WxRuby to crash by a) Parsing a file with Hpricot into an internal array of objects and assigning that to an instance variable on a Wx::Frame b) Running my script in Eclipse in "debug" mode and merely mousing over the the main Wx::Frame I've created Any suggestions? P.S. When's the .39 release for win32 going to be out? I keep checking and everyone else gets it but us unlucky saps needing to use a Windows box at work :( P H I L I P S C H A L M WebTeam at nic.bc.ca Web Developer North Island College - College Relations V: 250 334 5000 ext 4661 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070316/433ebd5e/attachment.html From rj.alexander at ukonline.co.uk Sat Mar 17 03:57:35 2007 From: rj.alexander at ukonline.co.uk (richard alexander) Date: Sat, 17 Mar 2007 07:57:35 +0000 Subject: [Wxruby-users] newbie: wxruby on fedora5 Message-ID: <1174118255.8409.20.camel@localhost.localdomain> the preview is looking good ! - the gem seemed to load fine but samples failed to load at all to start with: "load error: Wx" but got things running by pasting the set up stuff from Wx.rb into the demo file...haven't had time to figure out why yet. i copied over the copyright also, so now i've 2 in that file - lucky me. The unicode sample fell over on sys_lang get_system_encoding_name and the Tree control fell over on the constant Blue both probs seemed to be solved with begin/rescue blocks. From rj.alexander at ukonline.co.uk Sat Mar 17 06:43:54 2007 From: rj.alexander at ukonline.co.uk (richard alexander) Date: Sat, 17 Mar 2007 10:43:54 +0000 Subject: [Wxruby-users] newbie: listbook sample on fedora5 Message-ID: <1174128235.17343.8.camel@localhost.localdomain> opens a basic frame (empty) with following errors (wxruby:17165): Gtk-WARNING **: Attempting to add a widget with type GtkPizza to a GtkWindow, but as a GtkBin subclass a GtkWindow can only contain one widget at a time; it already contains a widget of type GtkPizza (wxruby:17165): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (wxruby:17165): Gtk-CRITICAL **: gtk_paint_flat_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed (wxruby:17165): Gdk-CRITICAL **: gdk_drawable_get_depth: assertion `GDK_IS_DRAWABLE (drawable)' failed (wxruby:17165): Gtk-CRITICAL **: gtk_paint_flat_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed does this from the ide and from a terminal session. Can't seem to fix this one. From rj.alexander at ukonline.co.uk Sat Mar 17 07:23:31 2007 From: rj.alexander at ukonline.co.uk (richard alexander) Date: Sat, 17 Mar 2007 11:23:31 +0000 Subject: [Wxruby-users] newbie: wxruby on fedora5 solved... In-Reply-To: <1174118255.8409.20.camel@localhost.localdomain> References: <1174118255.8409.20.camel@localhost.localdomain> Message-ID: <1174130612.17343.15.camel@localhost.localdomain> the solution was in the faq (thanks for the faq) "getting an error trying to run any wxruby2 application, such as the samples that are included in the gem - If you are using Linux, be sure you have configured your system to have: RUBYOPT=-rubygems" On Sat, 2007-03-17 at 07:57 +0000, richard alexander wrote: > the preview is looking good ! - the gem seemed to load fine but samples > failed to load at all to start with: > "load error: Wx" > but got things running by pasting the set up stuff from Wx.rb into the > demo file...haven't had time to figure out why yet. > i copied over the copyright also, so now i've 2 in that file - lucky me. > The unicode sample fell over on > sys_lang > get_system_encoding_name > and the Tree control fell over on the constant > Blue > both probs seemed to be solved with begin/rescue blocks. > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > From alex at pressure.to Sat Mar 17 20:28:47 2007 From: alex at pressure.to (Alex Fenton) Date: Sun, 18 Mar 2007 00:28:47 +0000 Subject: [Wxruby-users] newbie: listbook sample on fedora5 In-Reply-To: <1174128235.17343.8.camel@localhost.localdomain> References: <1174128235.17343.8.camel@localhost.localdomain> Message-ID: <45FC87BF.6090808@pressure.to> Hi richard richard alexander wrote: > opens a basic frame (empty) with following errors > (wxruby:17165): Gtk-WARNING **: Attempting to add a widget with type > GtkPizza to a GtkWindow, but as a GtkBin subclass a GtkWindow can only > contain one widget at a time; it already contains a widget of type > GtkPizza > Thanks for the report. Dunno what all this Pizza stuff is but it makes me hungry. I think this error with the Listbook sample on Linux has come up before, so it's very likely a reopened bug in wxruby2. I don't have a Linux box handy but will look into it when I do. Are you using 0.0.39 - let us know if not. cheers alex From alex at pressure.to Sat Mar 17 20:38:48 2007 From: alex at pressure.to (Alex Fenton) Date: Sun, 18 Mar 2007 00:38:48 +0000 Subject: [Wxruby-users] General segfaulting In-Reply-To: <2E853F7E065E754594F0B57044123C3402AA6DB9@cvcnt7.nic.bc.ca> References: <2E853F7E065E754594F0B57044123C3402AA6DB9@cvcnt7.nic.bc.ca> Message-ID: <45FC8A18.5050900@pressure.to> Hi Philip Philip Schalm wrote: > > I?m having issues with WxRuby segfaulting when it?s dealing with > external data in one form or another. > Thanks for the reports - I'd like to try this again once you have 0.0.39 as this addresses a substantial number of segfault bugs. I hope we'll have a binary build in the next few days. Covering the different platforms on wxruby takes a team of volunteers and we don't always have free time at the same time. I'll post a message to this list once we have a full 0.0.39 release ready. > > I can reliably force WxRuby to crash by > > a) Parsing a file with Hpricot into an internal array of objects and > assigning that to an instance variable on a Wx::Frame > > b) Running my script in Eclipse in ?debug? mode and merely mousing > over the the main Wx::Frame I?ve created > Not passing the buck, but I have had segfaults using Hpricot on its own. Could you post a sample of the html + code, or check that running that Hpricot code itself runs OK outside wxruby - perhaps with GC.start? I would really like to get 'debug' mode working on Eclipse but it always just hangs for me. Do you have GC.disable at the start of your script, and do you get the same behaviour if you launch the script (with -rdebug) from the command prompt? cheers alex From sean.m.long at gmail.com Sun Mar 18 03:07:06 2007 From: sean.m.long at gmail.com (Sean Long) Date: Sun, 18 Mar 2007 00:07:06 -0700 Subject: [Wxruby-users] newbie: listbook sample on fedora5 In-Reply-To: <45FC87BF.6090808@pressure.to> References: <1174128235.17343.8.camel@localhost.localdomain> <45FC87BF.6090808@pressure.to> Message-ID: This sample has never worked correctly in Linux, I wrote it way back using DialogBlocks to generate the XRC interface. It has always worked fine on OS X and Windows but nobody has figured out why it does not work on Linux. I think it is probably an XRC issue, it is a pretty silly sample anyway you are not missing much. Sean From alex at pressure.to Sun Mar 18 17:50:50 2007 From: alex at pressure.to (Alex Fenton) Date: Sun, 18 Mar 2007 21:50:50 +0000 Subject: [Wxruby-users] wxruby website/wiki Message-ID: <45FDB43A.2070507@pressure.to> Hi I've given the wxruby wiki/website a quick lick of CSS, and added some navigation to each page. Quite a lot of updated and re-organised content. http://wxruby.rubyforge.org/ I'm no Picasso so suggestions to make it less ugly are welcome. Even more, we'd like your content - it's a wiki so thrives on your contributions: * Screenshots - your app running on your platform * Questions - just add them and we'll try to answer * How Tos - notes on how some common tasks are handled in wxruby * Tutorials - more detailed explorations of particular widgets oh, and if anyone is a dab hand at logo design ... cheers alex From roys at mindspring.com Sun Mar 18 22:40:46 2007 From: roys at mindspring.com (Roy Sutton) Date: Sun, 18 Mar 2007 22:40:46 -0400 Subject: [Wxruby-users] Windows 0.0.39 gem uploaded Message-ID: <45FDF82E.5090200@mindspring.com> Sorry for the delay, the Windows gem for 0.0.39 has been uploaded to the files section. Roy From sean.m.long at gmail.com Mon Mar 19 01:24:15 2007 From: sean.m.long at gmail.com (Sean Long) Date: Sun, 18 Mar 2007 22:24:15 -0700 Subject: [Wxruby-users] wxruby website/wiki In-Reply-To: <45FDB43A.2070507@pressure.to> References: <45FDB43A.2070507@pressure.to> Message-ID: Alex, Nice job on the website, I like the look but especially like the navigation. Sean On 3/18/07, Alex Fenton wrote: > Hi > > I've given the wxruby wiki/website a quick lick of CSS, and added some > navigation to each page. Quite a lot of updated and re-organised content. > > http://wxruby.rubyforge.org/ > > I'm no Picasso so suggestions to make it less ugly are welcome. > > Even more, we'd like your content - it's a wiki so thrives on your > contributions: > > * Screenshots - your app running on your platform > * Questions - just add them and we'll try to answer > * How Tos - notes on how some common tasks are handled in wxruby > * Tutorials - more detailed explorations of particular widgets > > oh, and if anyone is a dab hand at logo design ... > > cheers > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > From alex at pressure.to Mon Mar 19 07:29:14 2007 From: alex at pressure.to (Alex Fenton) Date: Mon, 19 Mar 2007 11:29:14 +0000 Subject: [Wxruby-users] wxruby2-preview 0.0.39 is released Message-ID: <45FE740A.3030500@pressure.to> Hi all You've probably already clicked that 0.0.39 is available now in source and binaries for all the major platforms. This recommended upgrade is at: http://rubyforge.org/frs/?group_id=35&release_id=10372 = MAJOR CHANGES * lots of big and small bugfixes * New widget classes: ScrollBar, PasswordEntryDialog, MultiChoiceDialog * New misc classes: GridBagSizer, AcceleratorTable, IconBundle * New event classes: TextUrlEvent, MenuEvent, ContextMenuEvent * WINDOW_VARIANTS for OS X (make small and mini Aqua controls) * Lots of improvements and additions to the docs and samples = FURTHER DETAILS In particular, we hope we've fixed the very frequent crashes on Windows - please try running your scripts without GC.disable. This was caused by a regression when upgrading to SWIG 1.3.31 The large number of startup warnings on GTK should also be fixed, but there are still occasional warnings on Linux. Note that you should not try to initialise Pens, Brushes or Fonts outside of the App.main_loop, as this causes GTK warnings. There's one backwards-incompatible change - where previously TreeItemId.ok was called to test if it was a valid item, you should now do TreeItemId#nonzero? = NEXT STEPS Work on the next release is already well underway in SVN. In this version we'll be upgrading to WxWidgets 2.8, and hopefully releasing as a beta to reflect the increasing stability and completeness of wxRuby2. = CREDITS Many thanks to all who contributed code, builds and bug reports to this release, in particular Sean Long, Roy Sutton, Hawley Waldman and Paul Allton. Please report bugs, unexpected behaviour and missing features to the mailing list or the rubyforge tracker. cheers alex From Philip.Schalm at nic.bc.ca Mon Mar 19 11:44:58 2007 From: Philip.Schalm at nic.bc.ca (Philip Schalm) Date: Mon, 19 Mar 2007 08:44:58 -0700 Subject: [Wxruby-users] General segfaulting In-Reply-To: <45FC8A18.5050900@pressure.to> References: <2E853F7E065E754594F0B57044123C3402AA6DB9@cvcnt7.nic.bc.ca> <45FC8A18.5050900@pressure.to> Message-ID: <2E853F7E065E754594F0B57044123C3402AA6F33@cvcnt7.nic.bc.ca> Hi Alex, It appears that the issues were fixed with the 0.0.39 build of WxRuby, so I've got no more problems :D Cheers -----Original Message----- From: wxruby-users-bounces at rubyforge.org [mailto:wxruby-users-bounces at rubyforge.org] On Behalf Of Alex Fenton Sent: Saturday, March 17, 2007 5:39 PM To: General discussion of wxRuby Subject: Re: [Wxruby-users] General segfaulting Hi Philip Philip Schalm wrote: > > I'm having issues with WxRuby segfaulting when it's dealing with > external data in one form or another. > Thanks for the reports - I'd like to try this again once you have 0.0.39 as this addresses a substantial number of segfault bugs. I hope we'll have a binary build in the next few days. Covering the different platforms on wxruby takes a team of volunteers and we don't always have free time at the same time. I'll post a message to this list once we have a full 0.0.39 release ready. > > I can reliably force WxRuby to crash by > > a) Parsing a file with Hpricot into an internal array of objects and > assigning that to an instance variable on a Wx::Frame > > b) Running my script in Eclipse in "debug" mode and merely mousing > over the the main Wx::Frame I've created > Not passing the buck, but I have had segfaults using Hpricot on its own. Could you post a sample of the html + code, or check that running that Hpricot code itself runs OK outside wxruby - perhaps with GC.start? I would really like to get 'debug' mode working on Eclipse but it always just hangs for me. Do you have GC.disable at the start of your script, and do you get the same behaviour if you launch the script (with -rdebug) from the command prompt? cheers alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users From alex at pressure.to Thu Mar 22 06:14:48 2007 From: alex at pressure.to (Alex Fenton) Date: Thu, 22 Mar 2007 10:14:48 +0000 Subject: [Wxruby-users] WxSugar 0.1.14 is released Message-ID: <46025718.4060706@pressure.to> Hi I'm pleased to announce that a new version WxSugar is now available from http://rubyforge.org/frs/?group_id=35&release_id=10569 = CHANGES = * Can now just do "require 'wx_sugar'" to load all behaviours * Added 'find_window' and 'descendants' methods to Wx::Window * :name and :validator constructor arguments now work correctly for subclasses of Wx::Control * Added 'traverse' method to Wx::TreeCtrl * 'arrange_' methods now yield the underlying sizer into the block, which is a more useful behaviour esp if swapping windows in and out = INSTALLATION = (sudo) gem install wx_sugar or, from the tarball (sudo) rake install = NOTE = This version requires wxruby2-preview 0.0.39 to be installed. It will *not* work with the old series of wxruby (0.6.0) or earlier versions of wxruby2-preview. The bump in version number from 0.1.3 to 0.1.14 has no particular significance other than me doing a release too soon after waking up... we'll be releasing WxSugar as a stable version soon, as I think we've worked out most of the bugs in the current functionality. = CREDITS = Thanks to Paul Allton and Philip Schalms who pointed out some bugs and omissions fixed in this release. cheers Alex From paul.allton at uk.bnpparibas.com Tue Mar 27 08:56:44 2007 From: paul.allton at uk.bnpparibas.com (paul.allton at uk.bnpparibas.com) Date: Tue, 27 Mar 2007 13:56:44 +0100 Subject: [Wxruby-users] Test driving WxRuby2 apps In-Reply-To: <46025718.4060706@pressure.to> Message-ID: Before I forget, thanks for the new 0.0.39 and wx_sugar releases, excellent work guys - its great to see the back of GC.disable ;) I've been a bit tied up recently, so apologies that this topic has gone quiet ... but I just wanted to let you know that this isn't dead, in fact I've packaged up what I have so far into the attached gem. Please note: - wxruby2-preview 0.0.39 and wx_sugar 0.1.14 are required - this is very much a preview, it basically works - except for the problems listed in 'KNOWN ISSUES'. - component support is a bit thin right now, I've only added support for what I've needed to test an application that I'm currently building - it works on Windows and OS X only, as I've no means to test on other platforms. - its based on an generic GUI driving api called 'Nobbie', which is a very silly name, I won't bore you with the history of how it came about For usage info, please look at the README page of the gems rdoc ... but here is a quick example: require 'rubygems' require_gem 'nobbie-wx-preview' require 'your_application' #important - tell nobbie which application you want to test APPLICATION_UNDER_TEST = YourApp.new class YourAppTest < Test::Unit::TestCase def test_something_really_important assert !enabled?(:save) type 'fred', :first_name choosable(:male).choose selection(:title).choose 'Mr' assert enabled?(:save) click :save end end For more examples look at the 'test' directory under the gem install. Note that if you run all_tests.rb, some of the tests will currently fail (depending on platform), these tests expose some of the problems highlighted in 'KNOWN ISSUES'. p. .. This message and any attachments (the "message") is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. The internet can not guarantee the integrity of this message. BNP PARIBAS (and its subsidiaries) shall (will) not therefore be liable for the message if modified. ********************************************************************************************** BNP Paribas Private Bank London Branch is authorised by CECEI & AMF and is regulated by the Financial Services Authority for the conduct of its investment business in the United Kingdom. BNP Paribas Securities Services London Branch is authorised by CECEI & AMF and is regulated by the Financial Services Authority for the conduct of its investment business in the United Kingdom. BNP Paribas Fund Services UK Limited is authorised and regulated by the Financial Services Authority -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20070327/3f071802/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: nobbie-wx-preview-0.0.1.gem Type: application/octet-stream Size: 14848 bytes Desc: not available Url : http://rubyforge.org/pipermail/wxruby-users/attachments/20070327/3f071802/attachment-0001.obj From ac251404 at ohio.edu Thu Mar 29 19:48:36 2007 From: ac251404 at ohio.edu (Alex Ciarlillo) Date: Thu, 29 Mar 2007 19:48:36 -0400 Subject: [Wxruby-users] object-oriented GUI design and event handling Message-ID: <460C5054.4080706@ohio.edu> I'm trying to setup a fairly simple GUI with Ruby to perform some SQL queries. There are a few drop-down boxes where users can select different options and then one button that when clicked should get the text from each drop-down in order to perform the query. Once it gets the result it should display it to a text control. The problem is I am not sure how to actually reference each drop-down box in the frame or the text control. If I add the control directly to the frame there is no reference or name for that control that my button can later use. I have tried looking through sample code but most of the samples I found were for larger programs with many features and I couldn't really find the answer I was looking for. Could someone give me an idea of how to accomplish this or maybe a link to some reference that may help? It doesn't seem like it would be that difficult but I'm just not sure how to get started. Thanks, Alex Ciarlillo From pnomolos at gmail.com Fri Mar 30 00:08:18 2007 From: pnomolos at gmail.com (Philip Schalm) Date: Thu, 29 Mar 2007 21:08:18 -0700 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <460C5054.4080706@ohio.edu> References: <460C5054.4080706@ohio.edu> Message-ID: <39e69c8e0703292108i76cf262cgfca3438588a81c90@mail.gmail.com> Hi Alex, Are you doing this with WxSugar or solely with WxRuby2? If you're using WxSugar you could do something like the following: # Begin Code require 'wx' require 'wx_sugar' class MainFrame < Wx::Frame def initialize(*args) super @buttons = [] @buttons << add( Wx::Choice[ :choices => ("1".."5").to_a ] ) @buttons << add( Wx::Choice[ :choices => ("a".."e").to_a ] ) @buttons << add( Wx::Choice[ :choices => ("F".."J").to_a ] ) add( Wx::Button[ :label => 'Do Something'] ) do |button| listen(:button,button) do |event| @textctrl.value = @buttons.map{|but|but.string_selection}.join(',') end end @textctrl = add( Wx::TextCtrl[] ) end end class MyApp < Wx::App def on_init MainFrame.new( nil, :title => "SQL Application" ).show end end MyApp.new.main_loop # End Code As for plain WxRuby, it's a little more involved but will follow basically the same principles (I'd recommend WxSugar - it makes things much more rubyish) Cheers On 3/29/07, Alex Ciarlillo wrote: > I'm trying to setup a fairly simple GUI with Ruby to perform some SQL > ... > to get started. > > Thanks, > Alex Ciarlillo > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- -Phil <>< From alex at pressure.to Fri Mar 30 00:20:39 2007 From: alex at pressure.to (Alex Fenton) Date: Fri, 30 Mar 2007 05:20:39 +0100 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <460C5054.4080706@ohio.edu> References: <460C5054.4080706@ohio.edu> Message-ID: <460C9017.1030901@pressure.to> Hi Alex Alex Ciarlillo wrote: > I'm trying to setup a fairly simple GUI with Ruby to perform some SQL > queries. There are a few drop-down boxes where users can select > different options and then one button that when clicked should get the > text from each drop-down in order to perform the query. Once it gets the > result it should display it to a text control. The problem is I am not > sure how to actually reference each drop-down box in the frame or the > text control. For most simpler apps, the easiest way to reference widgets (e.g. a drop-down box) is to store it as a ruby instance variable of the containing frame when you create it. Then you can refer to them later in your event handler, either directly through an instance variable, or by ordinary ruby accessor methods. The latter is slightly more work, but as generally in ruby helps avoid typo errors and documents your frame class. A simple example using wxSugar might look something like: class SimpleFrame < Wx::Frame attr_reader :colour_ch, :size_ch, :results def initialize(parent) super(parent, :title => 'Database App') # set up some drop downs, an action button and a results display panel = add(Wx::Panel, :proportion => 1) panel.arrange_vertically(:padding => 8) do colours = %w[red blue green orange black] @colour_ch = panel.add( Wx::Choice[:choices => colours]) sizes = %w[small medium large] @size_ch = panel.add( Wx::Choice[:choices => sizes]) panel.add( Wx::Button[:label => 'Find' ] ) do | @button | listen(:button, @button, :on_find) end @results = panel.add( Wx::TextCtrl[:style => Wx::TE_MULTILINE], :proportion => 1) end end def on_find what_colour = colour_ch.string( colour_ch.selection ) what_size = size_ch.string( size_ch.selection ) # Do retrieval from the database here ... results.value = "Results for '#{what_colour}, #{what_size}' ..." end end hth alex From ac251404 at ohio.edu Fri Mar 30 15:39:57 2007 From: ac251404 at ohio.edu (Alex Ciarlillo) Date: Fri, 30 Mar 2007 15:39:57 -0400 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <460C9017.1030901@pressure.to> References: <460C5054.4080706@ohio.edu> <460C9017.1030901@pressure.to> Message-ID: <460D678D.9070700@ohio.edu> Thanks to both of you for getting me on the right track with this. Everything is coming together fine now except a problem I am having with CheckListBox. I would like the user to be able to select multiple items from certain lists so I thought this control would work, but now I can't figure out how to get at the selections. I changed colour_ch in Alex's example to a checklistbox but doing colour_ch.selections returns nothing. I read in the wxRuby docs that you are supposed to pass an array to be filled when using ListBox.get_selections but when I try that it gives me an error that I passed 1 argument where 0 is expected. I thought I would be able to do something like the following: what_colour = colour_ch.selections.map{|s| colour_ch.string(s)}.join(',') So that's my guess and even though its wrong I believe its clear that I'm just trying to get a comma seperated string of all the items selected in that control. How should I be attempting this? Thanks, -alex c. From pnomolos at gmail.com Fri Mar 30 16:44:07 2007 From: pnomolos at gmail.com (Philip Schalm) Date: Fri, 30 Mar 2007 13:44:07 -0700 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <460D678D.9070700@ohio.edu> References: <460C5054.4080706@ohio.edu> <460C9017.1030901@pressure.to> <460D678D.9070700@ohio.edu> Message-ID: <39e69c8e0703301344u52f02597m2d5ae0f7af4d975d@mail.gmail.com> Hi Alex C, Wx::ChecklistBox#selections() won't return the checked items - it will return the items that are selected (if you're on Windows, the ones that are highlighted blue in the control). To get a list of the checked items, do something like the following: what_colour = (0..(colour_ch.number)).to_a.map{ |n| colour_ch.string(n) }.join(',') (not sure if that's the exact syntax, but it should be close). As well, I'm not sure, but WxSugar might let you do something like the following: what_colour = colour_ch.each { |index| colour_ch.string(index) }.join(',') And, if that doesn't work right now, would that be something useful to add to WxSugar, Alex F? On 3/30/07, Alex Ciarlillo wrote: > Thanks to both of you for getting me on the right track with this. > Everything is coming together fine now except a problem I am having with > CheckListBox. I would like the user to be able to select multiple items > from certain lists so I thought this control would work, but now I can't > figure out how to get at the selections. I changed colour_ch in Alex's > example to a checklistbox but doing colour_ch.selections returns > nothing. I read in the wxRuby docs that you are supposed to pass an > array to be filled when using ListBox.get_selections but when I try that > it gives me an error that I passed 1 argument where 0 is expected. I > thought I would be able to do something like the following: > > what_colour = colour_ch.selections.map{|s| colour_ch.string(s)}.join(',') > > So that's my guess and even though its wrong I believe its clear that > I'm just trying to get a comma seperated string of all the items > selected in that control. How should I be attempting this? > > Thanks, > -alex c. > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > -- -Phil <>< From pnomolos at gmail.com Fri Mar 30 16:59:00 2007 From: pnomolos at gmail.com (Philip Schalm) Date: Fri, 30 Mar 2007 13:59:00 -0700 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <39e69c8e0703301344u52f02597m2d5ae0f7af4d975d@mail.gmail.com> References: <460C5054.4080706@ohio.edu> <460C9017.1030901@pressure.to> <460D678D.9070700@ohio.edu> <39e69c8e0703301344u52f02597m2d5ae0f7af4d975d@mail.gmail.com> Message-ID: <39e69c8e0703301359i79002321l3edb51757c419eb6@mail.gmail.com> I made an oopsie (that's in the documentation) ... Wx::ControlWithItems#number is not defined, you need to use Wx::ControlWithItems#count instead, so the first example should be: what_colour = (0..(colour_ch.count)).to_a.map{ |n| colour_ch.string(n) }.join(',') On 3/30/07, Philip Schalm wrote: > Hi Alex C, > > Wx::ChecklistBox#selections() won't return the checked items - it will > return the items that are selected (if you're on Windows, the ones > that are highlighted blue in the control). To get a list of the > checked items, do something like the following: > > what_colour = (0..(colour_ch.number)).to_a.map{ |n| > colour_ch.string(n) }.join(',') > > (not sure if that's the exact syntax, but it should be close). > As well, I'm not sure, but WxSugar might let you do something like the > following: > > what_colour = colour_ch.each { |index| colour_ch.string(index) }.join(',') > > And, if that doesn't work right now, would that be something useful to > add to WxSugar, Alex F? > > On 3/30/07, Alex Ciarlillo wrote: > > Thanks to both of you for getting me on the right track with this. > > Everything is coming together fine now except a problem I am having with > > CheckListBox. I would like the user to be able to select multiple items > > from certain lists so I thought this control would work, but now I can't > > figure out how to get at the selections. I changed colour_ch in Alex's > > example to a checklistbox but doing colour_ch.selections returns > > nothing. I read in the wxRuby docs that you are supposed to pass an > > array to be filled when using ListBox.get_selections but when I try that > > it gives me an error that I passed 1 argument where 0 is expected. I > > thought I would be able to do something like the following: > > > > what_colour = colour_ch.selections.map{|s| colour_ch.string(s)}.join(',') > > > > So that's my guess and even though its wrong I believe its clear that > > I'm just trying to get a comma seperated string of all the items > > selected in that control. How should I be attempting this? > > > > Thanks, > > -alex c. > > _______________________________________________ > > wxruby-users mailing list > > wxruby-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/wxruby-users > > > > > -- > -Phil <>< > -- -Phil <>< From alex at pressure.to Sat Mar 31 16:49:03 2007 From: alex at pressure.to (Alex Fenton) Date: Sat, 31 Mar 2007 21:49:03 +0100 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <460D678D.9070700@ohio.edu> References: <460C5054.4080706@ohio.edu> <460C9017.1030901@pressure.to> <460D678D.9070700@ohio.edu> Message-ID: <460EC93F.4060504@pressure.to> Alex Ciarlillo wrote: > Everything is coming together fine now except a problem I am having with > CheckListBox. I would like the user to be able to select multiple items > from certain lists so I thought this control would work, but now I can't > figure out how to get at the selections. .... > what_colour = colour_ch.selections.map{|s| colour_ch.string(s)}.join(',') > This is right. I've tried it out myself and I think there's a bug in CheckListBox - the method always seems to return [0]. This is a bit strange because the same method works fine in ListBox where the method is inherited from. Anyway I will look into it, hopefully can fix it pretty easily for the next release. I guess you could use ListBox in the interim - samples/bigdemo/wxListBox in the main wxruby2 dist illustrates how to use get_selections. Thanks for the report. alex From alex at pressure.to Sat Mar 31 17:07:34 2007 From: alex at pressure.to (Alex Fenton) Date: Sat, 31 Mar 2007 22:07:34 +0100 Subject: [Wxruby-users] object-oriented GUI design and event handling In-Reply-To: <39e69c8e0703301344u52f02597m2d5ae0f7af4d975d@mail.gmail.com> References: <460C5054.4080706@ohio.edu> <460C9017.1030901@pressure.to> <460D678D.9070700@ohio.edu> <39e69c8e0703301344u52f02597m2d5ae0f7af4d975d@mail.gmail.com> Message-ID: <460ECD96.60209@pressure.to> Philip Schalm wrote: > Wx::ChecklistBox#selections() won't return the checked items - it will > return the items that are selected (if you're on Windows, the ones > that are highlighted blue in the control). To get a list of the > checked items, do something like the following: > > what_colour = (0..(colour_ch.number)).to_a.map{ |n| > colour_ch.string(n) }.join(',') > Oops, I should have read this email first. Alex - ignore my previous email, Philip's quite right that get_selections doesn't return the checked items. The sort of thing you want is * items = (0 .. count).to_a checked = items.select { | i | checked?(i) }.map { | i | string(i) This works fine for me. *No bug ... I must be paranoid. > As well, I'm not sure, but WxSugar might let you do something like the > following: > > what_colour = colour_ch.each { |index| colour_ch.string(index) }.join(',') > > And, if that doesn't work right now, would that be something useful to > add to WxSugar, Alex F? > yes - I've been experimenting with some methods to improve working with ControlWithItems classes, but they didn't make it in the last release. We'll look to put it in the next one. thanks a