How do I get the selected state of a gtk::RadioButton in Rust?

In Python's Gtk module, you can use Gtk.RadioButton.get_active() to get whether the radio button is checked or not. However, I can't find any such method in Rust's equivalent, gtk::RadioButton. When I try to use RadioButton.active(), I get an error saying that the trait bounds were not satisfied for gtk::RadioButton. I've tried searching get(, active, checked, state, and selected in the docs, to no avail. This should be pretty self-explanatory, so I don't think I need to provide a code example. Does anyone know how to get the selected RadioButton in Rust (ideally without using a callback)?


If you look at the one-and-only official Gtk3 documentation, you'll see that RadioButton does not define an active property. Instead it is inherited from its base class ToggleButton.

AIUI, in gtk-rs, functions and properties inherited are actually part of the associated interface, not of the type itself. So your property is ToggleButtonExt::is_active().

In theory your RadioButton value implements IsA<ToggleButton> so it also implements ToggleButtonExt, and the is_active() method should be readily available.

If it says that the trait is not in scope maybe you forgot the use gtk::prelude::*;?