From: Paul Rubel Date: 2005-04-07T04:18:42+09:00 Subject: constrained gtk radio buttons 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. At a hight level I have two sets of radio buttons and want to change the selection of one set of buttons when a button in the other set is clicked. More specifically, the buttons represent a mouse. One side is button (Left, Right, Center,...) and the other is type of click (single, double, and drag). When L is selected any of the click types should be available. However, if R is selected and a user clicks on double I'd like to change from R to L as a double right doesn't seem very useful. On a click on double I'm able to call @left_button.set_state(true) and this changes from R to L as I'd expect. However, when I do this double doesn't get selected, single is still selected. The code below is my attempt to get this working. If you start it and click on right and then double you'll see what I described above. One interesting thing I do notice is that the first click on double prints out "clicked double" twice, which is odd. I suspect there is something in the event dispatching that I'm missing. Is there a better way to set the state of the button? Any help would be appreciated. thank you, Paul require 'gtk' class DwellWindow < Gtk::Window def initialize() super @single_button = Gtk::RadioButton.new(nil, "Single") @double_button = Gtk::RadioButton.new(@single_button,"Double") @double_button.signal_connect("clicked") {@left_button.set_state(true);puts " clicked double"} @left_button = Gtk::RadioButton.new(nil, "Left") @right_button = Gtk::RadioButton.new(@left_button, "Right") @right_button.signal_connect("clicked") {@single_button.set_state(true)} type_box = Gtk::VBox.new type_box.add(@single_button) type_box.add(@double_button) button_box = Gtk::VBox.new button_box.add(@left_button) button_box.add(@right_button) top_box = Gtk::HBox.new top_box.add(button_box) top_box.add(type_box) add(top_box) show_all end end dwell = DwellWindow.new Gtk::main