Ruby/gtk Which radiobutton

Hi!

Can anybody tell me how to figure out the currently selected radiobutton
in a group?

thx
Gergo

±[Kontra, Gergely @ Budapest University of Technology and Economics]-+

    Email: kgergely@mcl.hu,  kgergely@turul.eet.bme.hu          |

URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 |
±------“Olyan langesz vagyok, hogy poroltoval kellene jarnom!”-------+
.
Magyar php mirror es magyar php dokumentacio: http://hu.php.net

i think you use #active? like so:

gtk_radiobutton_object.active?

thus you have to loop through all the buttons in the group.

but don’t quote me on this :slight_smile:

~transami

···

On Fri, 2002-08-16 at 11:49, Kontra, Gergely wrote:

Hi!

Can anybody tell me how to figure out the currently selected radiobutton
in a group?

thx
Gergo

Kontra, Gergely wrote:

Can anybody tell me how to figure out the currently selected
radiobutton in a group?

This program will print the current radiobutton’s label if you press ‘p’
inside the window:

#v+
#!/usr/bin/env ruby
require ‘gtk’

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
window.signal_connect(‘destroy’) { Gtk.main_quit }
box = Gtk::VBox.new(false, 0); window.add box.show

group = nil
[“gtk”, “fox”, “tk”].each do |name|
button = Gtk::RadioButton.new(group, name)
group = button.group
box.add button
button.show
end

window.signal_connect(‘key_press_event’) { |widget, key|
if key.string == “p”
group.each { |b|
b.each { |label|
puts label.get_text if b.active?
}
}
end
}

window.show
Gtk.main
#v-

HTH,
Johannes

···

http://ffgrimmenstein.feuerwehr.org
Der Weg zum Wirt: http://www.wirtshauskultur.at