use eframe::egui; use rand::Rng; fn main() -> Result<(), eframe::Error> { let options = eframe::NativeOptions { initial_window_size: Some(egui::vec2(214.0, 100.0)), ..Default::default() }; // Our application state: let mut value = "0".to_owned(); eframe::run_simple_native("GUI component interaction", options, move |ctx, _frame| { egui::CentralPanel::default().show(ctx, |ui| { ui.horizontal(|ui| { let name_label = ui.label("Value: "); ui.text_edit_singleline(&mut value) .labelled_by(name_label.id); }); ui.horizontal(|ui| { if ui.button("Increment").clicked() { if let Ok(v) = value.parse::() { value = (v + 1).to_string() } } if ui.button("Random").clicked() { value = (rand::thread_rng().gen_range(1..=10000)).to_string(); } }); }); }) }