Function gtk_test::find_child_by_name
source · pub fn find_child_by_name<C: IsA<Widget>, W: Clone + IsA<Object> + IsA<Widget>>(
parent: &W,
name: &str
) -> Option<C>
Expand description
Returns the child element which has the given name.
Example:
extern crate gtk;
#[macro_use]
extern crate gtk_test;
use gtk::{prelude::BuildableExtManual, Button, prelude::ContainerExt, prelude::WidgetExt, Window, WindowType};
gtk::init().expect("GTK init failed");
let but = Button::new();
let w = Window::new(WindowType::Toplevel);
but.set_widget_name("Button");
w.add(&but);
gtk_test::find_child_by_name::<Button, Window>(&w, "Button").expect("failed to find child");
// Or even better:
let but: Button = gtk_test::find_child_by_name(&w, "Button").expect("failed to find child");