-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path7guis_counter.rs
31 lines (24 loc) · 886 Bytes
/
7guis_counter.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[macro_use]
extern crate iup;
use iup::prelude::*;
use iup::layout::HBox;
use iup::control::{Button, Text};
fn main() {
iup::with_iup(|| {
let mut text = Text::new()
.set_attrib("VALUE", "0")
.set_attrib("READONLY", "YES");
let button = Button::with_title("Count")
.set_action(move |_| {
let count = text.attrib("VALUE").unwrap().parse::<i32>().unwrap();
text.set_attrib("VALUE", (count + 1).to_string());
});
let mut dialog = Dialog::new(
HBox::new(elements![text, button])
.set_attrib("ALIGNMENT", "ACENTER")
.set_attrib("MARGIN", "10x10")
.set_attrib("GAP", "10")
);
dialog.show()
}).unwrap();
}