mirror of
https://github.com/danbulant/cushy
synced 2026-05-21 13:18:48 +00:00
18 lines
614 B
Rust
18 lines
614 B
Rust
use gooey::value::Dynamic;
|
|
use gooey::widgets::Button;
|
|
use gooey::Run;
|
|
|
|
fn main() -> gooey::Result {
|
|
// begin rustme snippet: readme
|
|
// Create a dynamic usize.
|
|
let count = Dynamic::new(0_usize);
|
|
|
|
// Create a new button with a label that is produced by mapping the contents
|
|
// of `count`.
|
|
Button::new(count.map_each(ToString::to_string))
|
|
// Set the `on_click` callback to a closure that increments the counter.
|
|
.on_click(count.with_clone(|count| move |_| count.set(count.get() + 1)))
|
|
// Run the button as an an application.
|
|
.run()
|
|
// end rustme snippet
|
|
}
|