# From RubyCocoa to wxRuby?

**URL:** <https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242>\
**Category:** wxRuby\
**Created:** [May 10, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242 "2008-05-10T16:47:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yvon\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecc23a/32.png) [@Yvon\_T](https://www.ruby-forum.com/u/Yvon_T)\
**Post date:** [May 10, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242/1 "2008-05-10T16:47:47Z")

</div>

hey all,

thanks to alex who help me to get the latest running on my box ( Mac OS  
X  
10.4.11)

to get it working download the latest gem locally cd to the directory  
where  
it lies and :  
$ sudo gem install --local wxruby

u’ll get :  
Successfully installed wxruby-1.9.7-universal-darwin-9  
1 gem installed

😉

A question, my first test will be to convert a RubyCocoa project into  
wxRuby.

this project convert the AddressBook contents into html  
( a preview :  
[http://thoraval.yvon.free.fr/AB2Html\_preview/ab2html.xhtml](http://thoraval.yvon.free.fr/AB2Html_preview/ab2html.xhtml)

what do I need ?

a push button, a spinner and a text area to give feedback to the user  
that’  
all 😉

( a screenshot : [http://cjoint.com/data/fkqRia4sT5.htm](http://cjoint.com/data/fkqRia4sT5.htm)

what is the best example to start with in such a context ?

is it possible to use the AddressBook framework from wxRuby ?

in that case i’ll only the UI to rewrite…

best,

yvon

---

<div class="post-metadata">

**Author:** ![Yvon\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecc23a/32.png) [@Yvon\_T](https://www.ruby-forum.com/u/Yvon_T)\
**Post date:** [May 10, 2008, 6:01pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242/2 "2008-05-10T18:01:31Z")

</div>

2008/5/10 Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Glad we figured it out. Something that other users may want to be aware of  
> is that Rubygems seems not to be offering the latest gems to OS X 10.4  
> users.

this is true for rubygems itself..  
i was unable to update to \*  
1.1.1[http://rubyforge.org/frs/shownotes.php?release\_id=21058](http://rubyforge.org/frs/shownotes.php?release_id=21058)

- 
  - of 11/04/2008 00:06, may be i’ll try again with the same  
procedure…\*

> A question, my first test will be to convert a RubyCocoa project into
> 
> > wxRuby.
> 
> Out of interest, may I ask why you’re looking to make this switch?

threads probs with RubyCocoa ?  
Xplatform too  
also this project is the simplest to start with wxRuby.

> > 
> 
> Sizers are the best way to lay out widgets; there is a reasonably detailed  
> discussion of how to use them in the documentation for Wx::Sizer.
> 
> is it possible to use the AddressBook framework from wxRuby ?
> 
> > 
> 
> You should be able to use RubyCocoa to access that framework without  
> problems inside wxRuby. It’s not something I know much about though.

i know that part, i’ve done ruby script to extend some of this framework  
classes (ABGroup, ABPerson and ABAddressBook.sharedAddressBook class  
instance)

in that case i’ll only the UI to rewrite…

> > 
> 
> Yep, well hopefully if your existing code has the UI and export code  
> reasonably separate it shouldn’t be a tricky job.

my export code is as simple as :  
@address\_book.to\_xml

(each classe has it’s own #to\_xml method…)  
the remaining code is devoted to save files at the right place (under  
~/Sites)

> good luck and feel free to ask for help on this list

thanks for your advices !

---

<div class="post-metadata">

**Author:** ![Yvon\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecc23a/32.png) [@Yvon\_T](https://www.ruby-forum.com/u/Yvon_T)\
**Post date:** [May 10, 2008, 5:36pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242/3 "2008-05-10T17:36:18Z")

</div>

Yvon T. wrote:

> thanks to alex who help me to get the latest running on my box ( Mac  
> OS X 10.4.11)
> 
> to get it working download the latest gem locally cd to the directory  
> where it lies and :  
> $ sudo gem install --local wxruby
> 
> u’ll get :  
> Successfully installed wxruby-1.9.7-universal-darwin-9  
> 1 gem installed

Glad we figured it out. Something that other users may want to be aware  
of is that Rubygems seems not to be offering the latest gems to OS X  
10.4 users.

> A question, my first test will be to convert a RubyCocoa project into  
> wxRuby.  
> Out of interest, may I ask why you’re looking to make this switch?

> what is the best example to start with in such a context ?

The classes you want will be Wx::Button, Wx::AnimationCtrl, and  
Wx::StaticText or Wx::TextCtrl. You may want to place them all on a  
Wx::Panel.

For a sample to use as a starting point, you could look at  
text/textctrl.rb which organises a few widgets using sizers and links up  
a button event. Sizers are the best way to lay out widgets; there is a  
reasonably detailed discussion of how to use them in the documentation  
for Wx::Sizer.

> is it possible to use the AddressBook framework from wxRuby ?

You should be able to use RubyCocoa to access that framework without  
problems inside wxRuby. It’s not something I know much about though.

> in that case i’ll only the UI to rewrite…

Yep, well hopefully if your existing code has the UI and export code  
reasonably separate it shouldn’t be a tricky job.

good luck and feel free to ask for help on this list

alex

---

<div class="post-metadata">

**Author:** ![Yvon\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecc23a/32.png) [@Yvon\_T](https://www.ruby-forum.com/u/Yvon_T)\
**Post date:** [May 10, 2008, 6:13pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242/4 "2008-05-10T18:13:19Z")

</div>

Yvon T. wrote:\*\*

> ```
> A question, my first test will be to convert a RubyCocoa
> project into wxRuby.
> 
> Out of interest, may I ask why you're looking to make this switch?
> 
> ```
> 
> threads probs with RubyCocoa ?

If you need to use ruby threads in your application, also look at the  
threaded.rb sample. Threads work OK with wxRuby, but you need to make  
sure that the background non-GUI tasks are allocated some time, and try  
to avoid calling GUI code outside the main thread. There are numerous  
threads about threads on the mailing list.

a

---

<div class="post-metadata">

**Author:** ![Yvon\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ecc23a/32.png) [@Yvon\_T](https://www.ruby-forum.com/u/Yvon_T)\
**Post date:** [May 10, 2008, 8:39pm UTC](https://www.ruby-forum.com/t/from-rubycocoa-to-wxruby/137242/5 "2008-05-10T20:39:41Z")

</div>

2008/5/10 Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Yvon T. wrote:\*\*
> 
> > threads probs with RubyCocoa ?
> 
> If you need to use ruby threads in your application, also look at the  
> threaded.rb sample. Threads work OK with wxRuby, but you need to make sure  
> that the background non-GUI tasks are allocated some time, and try to avoid  
> calling GUI code outside the main thread.

ok, i see.

> There are numerous threads about threads on the mailing list.

😉
