# Wxruby and trayicon error and where to learn more about wxru

**URL:** <https://www.ruby-forum.com/t/wxruby-and-trayicon-error-and-where-to-learn-more-about-wxru/112797>\
**Category:** Ruby\
**Created:** [August 23, 2007, 11:50am UTC](https://www.ruby-forum.com/t/wxruby-and-trayicon-error-and-where-to-learn-more-about-wxru/112797 "2007-08-23T11:50:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kazaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b4bc9f/32.png) [@kazaam](https://www.ruby-forum.com/u/kazaam)\
**Post date:** [August 23, 2007, 11:50am UTC](https://www.ruby-forum.com/t/wxruby-and-trayicon-error-and-where-to-learn-more-about-wxru/112797/1 "2007-08-23T11:50:09Z")

</div>

Hi,  
I’m working with wxruby since 2 days but next to this Wiki:  
[http://wxruby.rubyforge.org/wiki/wiki.pl](http://wxruby.rubyforge.org/wiki/wiki.pl) and this Doc:  
[http://wxruby.rubyforge.org/doc/](http://wxruby.rubyforge.org/doc/) I couldn’t find something usefull for  
it. Also [del.icio.us](http://del.icio.us) has no intresting links. Do you know any good  
website or book about wxruby?

My problem at the moment is, I wanna test the TaskBarIcon on Gnome and  
so I did:

#!/usr/bin/env ruby

$Verbose=true

require ‘rubygems’  
require ‘wx’

include Wx

class MinimalApp \< App

```
def on_init
    mytask = TaskBarIcon.new
    mytask.set_icon('shutdown.svg','thats my tooltip')
end

```

end

MinimalApp.new.main\_loop

#eof

the doc tells about set\_icon:  
Boolean set\_icon(Icon icon, String tooltip)  
Sets the icon, and optional tooltip text.

shutdown.svg is an Icon and next to it comes a string, so it should be  
right or? But executed I’m always getting this error:

./task.rb:15:in `set_icon': in method 'SetIcon', argument 2 of type 'wxIcon const &' (TypeError) from ./task.rb:15:in `on\_init’  
from ./task.rb:21:in `main\_loop’  
from ./task.rb:21

Someone knows why this happens?

greets

---

<div class="post-metadata">

**Author:** ![kazaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b4bc9f/32.png) [@kazaam](https://www.ruby-forum.com/u/kazaam)\
**Post date:** [August 23, 2007, 12:21pm UTC](https://www.ruby-forum.com/t/wxruby-and-trayicon-error-and-where-to-learn-more-about-wxru/112797/2 "2007-08-23T12:21:11Z")

</div>

Alle giovedì 23 agosto 2007, kazaam ha scritto:

> #!/usr/bin/env ruby
> 
> #eof  
> from ./task.rb:21:in `main\_loop’  
> from ./task.rb:21
> 
> Someone knows why this happens?
> 
> greets

‘shutdown.svg’ is not a Wx::Icon, it’s a string. I didnt’ look at the  
wxWidgets documentation in detail, but I think you need to do something  
like  
the following:

bitmap = Wx::Bitmap.new  
bitmap.load\_file ‘shutdown.png’, Wx::BITMAP\_TYPE\_PNG  
icon = Icon.new  
icon.copy\_from\_bitmap  
mytask.set\_icon icon, ‘tooltip’

or (I’m not sure whether you can load png files directly using  
Icon#load\_file)

icon = Icon.new  
icon.load\_file ‘shutdown.png’, Wx::BITMAP\_TYPE\_PNG  
mytask.set\_icon icon, ‘tooltip’

At any rate, I don’t think you can load svg images. The documentation  
seems to  
say that only raster image types are supported.

I hope this helps

Stefano

---

<div class="post-metadata">

**Author:** ![kazaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b4bc9f/32.png) [@kazaam](https://www.ruby-forum.com/u/kazaam)\
**Post date:** [August 23, 2007, 4:06pm UTC](https://www.ruby-forum.com/t/wxruby-and-trayicon-error-and-where-to-learn-more-about-wxru/112797/3 "2007-08-23T16:06:45Z")

</div>

I got help somewhere else. The icon must be loaded before, so this works  
correctly:

#!/usr/bin/env ruby

$Verbose=true

require ‘rubygems’  
require ‘wx’

include Wx

class MinimalApp \< App

```
def on_init
    mytask = TaskBarIcon.new
    mytask.set_icon( Icon.new('shutdown.svg'),'test tooltip')
end

```

end

MinimalApp.new.main\_loop
