Hello,
I would like to sub-class the Ruby/Tk iwidget combobox class.
I want to be able to post several commands when the "return" key is
pressed on the entry of my objects but I also want to preserve the
default combobox insertion functionality (new entries are automatically
inserted in the scrolled list)
The class code could be like ...
class MyCombobox << Tk::Iwidgets::Combobox
def initialize(parent, *args)
super(parent, *args)
...
@commands =
[] # array of
commands
@commands << cget(:command) if cget(:command) !=
"" # the first command launched will be the default
command
configure :command=>proc {val=get;@commands.each {|c|
c.call(val)}} # launch all commands when a new entry
...
end
attr_reader :commands
...
end
... and the usage ...
cbb = MyCombobox.new...
cbb.commands << proc {|val| puts "new entry #{val}"}
The problem is that this code is not working because the default
combobox command is a Tcl command (not a ruby proc).
So, my questions:
- is there a simple (and portable) way to launch Tcl commands from ruby ?
- is there a more elegant way to add a list of ruby commands while
preserving default Tcl/Tk megawidget functionalities ?
- is there any documentation/help on Ruby/Tk and ruby Tk extensions ?
(without having to understand the full code)
Thanks a lot for your help and regards,
Lionel Maiaux