# Help with wxSugar please

**URL:** <https://www.ruby-forum.com/t/help-with-wxsugar-please/90436>\
**Category:** Ruby\
**Created:** [March 28, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/help-with-wxsugar-please/90436 "2007-03-28T21:08:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![combas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@combas](https://www.ruby-forum.com/u/combas)\
**Post date:** [March 28, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/help-with-wxsugar-please/90436/1 "2007-03-28T21:08:44Z")

</div>

I am playing around with making some sort of GUI in ruby and have settle  
on wxRuby. I stumbled across wxSugar and the sample code here:  
[http://wxruby.rubyforge.org/wiki/wiki.pl?WxSugar](http://wxruby.rubyforge.org/wiki/wiki.pl?WxSugar)  
but that code does not run!?

It is saying that all the methods associated with Wx::Choice that he  
uses (each\_string, strings[], data[], delete\_if) do not exist and I have  
no clue why. I cannot find ANY documentation on wxSugar so I’m not sure  
how I’m supposed to pick it up.

Also, in that example code he adds Wx::Choice and a Wx::TextCtrl, but  
how can I get to the data in these controls? I know the method is  
something like choice.get\_current\_selection(), but how do I reference it  
anywhere if it has no identifier or name? For example if I selected  
something from the Wx::Choice and I want that selection to print to the  
screen when I click a button, how do I access that selection in the  
button code?

thanks  
-alex

---

<div class="post-metadata">

**Author:** ![combas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@combas](https://www.ruby-forum.com/u/combas)\
**Post date:** [March 28, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/help-with-wxsugar-please/90436/2 "2007-03-28T21:31:22Z")

</div>

In message [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid), Alex  
Ciarlillo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes

> Also, in that example code he adds Wx::Choice and a Wx::TextCtrl, but  
> how can I get to the data in these controls? I know the method is  
> something like choice.get\_current\_selection(), but how do I reference it  
> anywhere if it has no identifier or name? For example if I selected  
> something from the Wx::Choice and I want that selection to print to the  
> screen when I click a button, how do I access that selection in the  
> button code?
> 
> thanks  
> -alex

Question for: removed\_email\_address@domain.invalid ?

Regards,

Alec

---

<div class="post-metadata">

**Author:** ![combas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/aca169/32.png) [@combas](https://www.ruby-forum.com/u/combas)\
**Post date:** [March 29, 2007, 1:00am UTC](https://www.ruby-forum.com/t/help-with-wxsugar-please/90436/3 "2007-03-29T01:00:48Z")

</div>

Hi Alex

Alex C. wrote:

> It is saying that all the methods associated with Wx::Choice that he  
> uses (each\_string, strings[], data[], delete\_if) do not exist and I have  
> no clue why.

Apologies, these methods in the development version but not in current  
release. Take a look at samples/sugar\_sample.rb as a starting point.

I’ve updated the Wiki so it’s not out of line.

> I cannot find ANY documentation on wxSugar so I’m not sure  
> how I’m supposed to pick it up.

You should find reasonably thorough RDoc documentation installed with  
the gem, or have a look at lib/wx\_sugar.rb for an overview of the  
functionality.

> Also, in that example code he adds Wx::Choice and a Wx::TextCtrl, but  
> how can I get to the data in these controls? I know the method is  
> something like choice.get\_current\_selection(), but how do I reference it  
> anywhere if it has no identifier or name? For example if I selected  
> something from the Wx::Choice and I want that selection to print to the  
> screen when I click a button, how do I access that selection in the  
> button code?

This is probably more a question about object-oriented design of GUI  
apps, and of event handling in particular. As others have suggested, the  
wxruby-users list is likely the best place to discuss how this is done  
in wxruby.

cheers  
alex
