Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > wxruby and trayicon error and where to learn more about wxruby?

Reply
Thread Tools

wxruby and trayicon error and where to learn more about wxruby?

 
 
kazaam
Guest
Posts: n/a
 
      08-23-2007
Hi,
I'm working with wxruby since 2 days but next to this Wiki: http://wxruby.rubyforge.org/wiki/wiki.pl and this Doc: http://wxruby.rubyforge.org/doc/ I couldn't find something usefull for it. Also 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

--
kazaam <>
 
Reply With Quote
 
 
 
 
kazaam
Guest
Posts: n/a
 
      08-23-2007
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

--
kazaam <>
 
Reply With Quote
 
 
 
 
Stefano Crocco
Guest
Posts: n/a
 
      08-23-2007
Alle gioved=EC 23 agosto 2007, kazaam ha scritto:
> Hi,
> I'm working with wxruby since 2 days but next to this Wiki:
> http://wxruby.rubyforge.org/wiki/wiki.pl and this Doc:
> http://wxruby.rubyforge.org/doc/ I couldn't find something usefull for it.
> Also 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=3Dtrue
>
> require 'rubygems'
> require 'wx'
>
> include Wx
>
>
> class MinimalApp < App
>
> def on_init
> mytask =3D 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 'wxIc=

on
> 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



'shutdown.svg' is not a Wx::Icon, it's a string. I didnt' look at the=20
wxWidgets documentation in detail, but I think you need to do something lik=
e =20
the following:

bitmap =3D Wx::Bitmap.new
bitmap.load_file 'shutdown.png', Wx::BITMAP_TYPE_PNG
icon =3D 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_fi=
le)

icon =3D 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=20
say that only raster image types are supported.

I hope this helps

Stefano

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some information for the one who decided to learn C++, and now wantsto learn at least a bit of C? Alexander C Programming 20 09-11-2010 01:04 AM
awt.TrayIcon prakash.bande@altair.com Java 0 01-16-2008 06:42 PM
Strange GUI freezing TrayIcon + PopupMenu, please help kermitas@gmail.com Java 3 03-22-2007 04:59 PM
Gnome panel applets and Gtk2::TrayIcon tdelov@gmail.com Perl Misc 0 08-30-2006 03:14 AM
newbie question: should I learn TKinter or skip it and learn more advanced toolkit? Porky Pig Jr Python 3 05-12-2004 08:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57