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

Discussion in 'Ruby' started by kazaam, Aug 23, 2007.

  1. kazaam

    kazaam Guest

    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 <>
     
    kazaam, Aug 23, 2007
    #1
    1. Advertising

  2. kazaam

    kazaam Guest

    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 <>
     
    kazaam, Aug 23, 2007
    #2
    1. Advertising

  3. 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
     
    Stefano Crocco, Aug 23, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Porky Pig Jr
    Replies:
    3
    Views:
    1,093
    Fuzzyman
    May 12, 2004
  2. Replies:
    3
    Views:
    468
  3. awt.TrayIcon

    , Jan 16, 2008, in forum: Java
    Replies:
    0
    Views:
    313
  4. Alexander
    Replies:
    20
    Views:
    1,073
    BGB / cr88192
    Sep 11, 2010
  5. Replies:
    0
    Views:
    124
Loading...

Share This Page