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@oleco.net>
Hello Kazaam, Afraid that there isn''t much documentation towards wxRuby, aside from the wiki and doc on those links you have provided already. The problem with what is going on with your file, is that you first need to create/load an icon, before you can pass it to TaskBarIcon#set_icon(). To do this, there is one of two ways, you create the icon via Wx::Icon.load(filename) or Wx::Icon.new(filename). WxRuby can only handle certian file formats, and I don''t know if SVG is one of those or not. You will need to check and see if SVG is enabled. The Second method, is you can indirectly load a Bitmap first, then create an Icon for the next part. Example being: bitmap = Wx::Bitmap.load("mybitmap.ext") icon = Wx::Icon.new(bitmap) This is not a comprehensive example of how this works, but gives you the ground work in which to make what you want done, to get there. Have fun, and always feel free to ask for help from here, someone is bound to answer. ;-) Mario Steele kazaam wrote:> 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 > > >
Hi Mario thanks alot for your help! :) It works nice, also with *.svg files: #!/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 at oleco.net>
kazaam wrote:> the doc tells about set_icon: > Boolean set_icon(Icon icon, String tooltip) >Mario''s already given you a good answer, but just as a general hint in reading the wxRuby docs: - in the argument list, the grey capitalised first part of each argument (eg "Icon") is the ruby class of the object that''s expected. So if it''s "Icon", it wants a Wx::Icon, if it''s "String" it wants a ruby String.> 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: >Wow, cool, I never knew that wxRuby handled SVG icons. I expect this is GTK only though..> ./task.rb:15:in `set_icon'': in method ''SetIcon'', argument 2 of type ''wxIcon const &'' (TypeError)it''s a bit confusing - "argument 2" here means the first argument to ruby - this is a SWIG idiocy that it reports errors from a C++ perspective... Though the class reference docs are pretty comprehensive, I know they''re not always that helpful getting an overall idea of how to use a class. There is an excellent book on wxWidgets programming which used to be available as a free PDF. Although the examples are in C++, it''s got lots and lots of ideas and detailed discussion of how the wxRuby classes work. Alex
Another question: someone knows any apps already written with wxruby? I''d like to read them to learn from them. The doc is definitivly not enough for me.. Right now I''m trying a popup-menu when clicking on the taskbaricon but the doc tells: It is recommended to override create_popup_icon callback instead of calling this method from event handler, because some ports (e.g. Cocoa) may not implement PopupMenu and mouse click events at all. Alright "override create_popup_icon callback" sounds like chinese to me :))) It would really help reading some example-codes or -programs but I can''t find any with google. Can someone point me to any code? greets -- kazaam <kazaam at oleco.net>
k thanks, I will look for this pdf-file on wxwidgets although my c++ is nearly enough for an "hello-world", I''ll give it a try. greets On Thu, 23 Aug 2007 11:14:49 +0100 Alex Fenton <alex at pressure.to> wrote:> kazaam wrote: > > the doc tells about set_icon: > > Boolean set_icon(Icon icon, String tooltip) > > > Mario''s already given you a good answer, but just as a general hint in > reading the wxRuby docs: - in the argument list, the grey capitalised > first part of each argument (eg "Icon") is the ruby class of the object > that''s expected. So if it''s "Icon", it wants a Wx::Icon, if it''s > "String" it wants a ruby String. > > 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: > > > Wow, cool, I never knew that wxRuby handled SVG icons. I expect this is > GTK only though.. > > ./task.rb:15:in `set_icon'': in method ''SetIcon'', argument 2 of type ''wxIcon const &'' (TypeError) > it''s a bit confusing - "argument 2" here means the first argument to > ruby - this is a SWIG idiocy that it reports errors from a C++ > perspective... > > Though the class reference docs are pretty comprehensive, I know they''re > not always that helpful getting an overall idea of how to use a class. > There is an excellent book on wxWidgets programming which used to be > available as a free PDF. Although the examples are in C++, it''s got lots > and lots of ideas and detailed discussion of how the wxRuby classes work. > > Alex > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users-- kazaam <kazaam at oleco.net>
kazaam wrote:> Another question: someone knows any apps already written with wxruby? I''d like to read them to learn from them. The doc is definitivly not enough for me.. Right now I''m trying a popup-menu when clicking on the taskbaricon but the doc tells: > It is recommended to override create_popup_icon callback instead of calling this method from event handler, because some ports (e.g. Cocoa) may not implement PopupMenu and mouse click events at all. > Alright "override create_popup_icon callback" sounds like chinese to me :)))The best place to start is probably the wxruby samples. If you installed from a gem, these will be in your gems directory. There''s illustrations of how to use almost all the GUI classes in there (although the code is sometimes a bit ugly) - when I want to remember how to use Wx:XXX I often just search for that class''s name in those files. I know there is an illustration of how to create a popup menu with a TaskBarIcon in there (in samples/bigdemo.rb) There are a couple of bigger applications written using wxRuby - see here: http://wxruby.rubyforge.org/wiki/wiki.pl?OnlineCodeExamples or search rubyforge for ''wxruby'' to turn up some other projects at various stages of development alex
And again thanks :) I found the samples and will start reading them now. greets On Thu, 23 Aug 2007 11:32:25 +0100 Alex Fenton <alex at pressure.to> wrote:> kazaam wrote: > > Another question: someone knows any apps already written with wxruby? I''d like to read them to learn from them. The doc is definitivly not enough for me.. Right now I''m trying a popup-menu when clicking on the taskbaricon but the doc tells: > > It is recommended to override create_popup_icon callback instead of calling this method from event handler, because some ports (e.g. Cocoa) may not implement PopupMenu and mouse click events at all. > > Alright "override create_popup_icon callback" sounds like chinese to me :))) > The best place to start is probably the wxruby samples. If you installed > from a gem, these will be in your gems directory. There''s illustrations > of how to use almost all the GUI classes in there (although the code is > sometimes a bit ugly) - when I want to remember how to use Wx:XXX I > often just search for that class''s name in those files. I know there is > an illustration of how to create a popup menu with a TaskBarIcon in > there (in samples/bigdemo.rb) > > There are a couple of bigger applications written using wxRuby - see here: > http://wxruby.rubyforge.org/wiki/wiki.pl?OnlineCodeExamples > > or search rubyforge for ''wxruby'' to turn up some other projects at > various stages of development > > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users-- kazaam <kazaam at oleco.net>