Joao Pedrosa
4/6/2005 8:01:00 PM
Hi,
On Apr 6, 2005 4:18 PM, Paul Rubel <prubel@bbn.com> wrote:
> Hello,
>
> I've been trying out gtk and gtk2 for the first time over the past few
> days. Overall it has been a good experience. At the moment however,
> I'm stumped and was hoping someone might be able to enlighten me.
I've created a sample that works with Ruby-GNOME2. When a Radiobutton
is activated, it triggers the "clicked" event, even when the
activation is thru code, so I created a method to handle that. I've
never used GTK 1.x so I can't test your version. :-) Follows:
require 'gtk2'
class DwellWindow < Gtk::Window
def initialize()
super
@single_button = Gtk::RadioButton.new("Single")
@double_button = Gtk::RadioButton.new(@single_button,"Double")
@double_button.signal_connect("clicked") {activate_button(@left_button)}
@left_button = Gtk::RadioButton.new("Left")
@right_button = Gtk::RadioButton.new(@left_button, "Right")
@right_button.signal_connect("clicked") {activate_button(@single_button)}
type_box = Gtk::VBox.new
type_box.pack_start @single_button, true, true, 0
type_box.pack_start @double_button, true, true, 0
button_box = Gtk::VBox.new
button_box.pack_start @left_button, true, true, 0
button_box.pack_start @right_button, true, true, 0
top_box = Gtk::HBox.new
top_box.pack_start button_box, true, true, 0
top_box.pack_start type_box, true, true, 0
add(top_box)
show_all
end
def activate_button b
if not @activating
@activating = true
b.active = true
@activating = nil
end
end
end
Gtk.init
dwell = DwellWindow.new
dwell.show_all
Gtk::main
-------------
Cheers,
Joao