728x90
반응형
프로젝트 만들기
Cargo.tomi
다음 추가
native-windows-gui = "1.0.12"
native-windows-derive = "1.0.3"
[package]
name = "ex04"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
native-windows-gui = "1.0.12"
native-windows-derive = "1.0.3"
main.rs
#![windows_subsystem = "windows"]
/*!
A very simple application that shows your name in a message box.
Unlike `basic_d`, this example uses layout to position the controls in the window
*/
extern crate native_windows_gui as nwg;
extern crate native_windows_derive as nwd;
use nwd::NwgUi;
use nwg::NativeUi;
#[derive(Default, NwgUi)]
pub struct BasicApp {
#[nwg_control(size: (300, 115), position: (300, 300), title: "Basic example", flags: "WINDOW|VISIBLE")]
#[nwg_events( OnWindowClose: [BasicApp::say_goodbye] )]
window: nwg::Window,
#[nwg_layout(parent: window, spacing: 1)]
grid: nwg::GridLayout,
#[nwg_control(text: "Abcd", focus: true)]
#[nwg_layout_item(layout: grid, row: 0, col: 0)]
name_edit: nwg::TextInput,
#[nwg_control(text: "Show Input")]
#[nwg_layout_item(layout: grid, col: 0, row: 1, row_span: 2)]
#[nwg_events( OnButtonClick: [BasicApp::say_hello] )]
hello_button: nwg::Button
}
impl BasicApp {
fn say_hello(&self) {
nwg::modal_info_message(&self.window, "Hello", &format!("Hello {}", self.name_edit.text()));
}
fn say_goodbye(&self) {
nwg::modal_info_message(&self.window, "Goodbye", &format!("Goodbye {}", self.name_edit.text()));
nwg::stop_thread_dispatch();
}
}
fn main() {
nwg::init().expect("Failed to init Native Windows GUI");
nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
let _app = BasicApp::build_ui(Default::default()).expect("Failed to build UI");
nwg::dispatch_thread_events();
}
GitHub - gabdube/native-windows-gui: A light windows GUI toolkit for rust
GitHub - gabdube/native-windows-gui: A light windows GUI toolkit for rust
A light windows GUI toolkit for rust. Contribute to gabdube/native-windows-gui development by creating an account on GitHub.
github.com
728x90
반응형
'프로그램' 카테고리의 다른 글
[파이썬] 문제 : 크롤링에서 특정 데이터만 가져오기(네이버 재무정보) (2) | 2023.05.27 |
---|---|
[파이썬] 문제 : 추상클래스 Polygon과 자식클래스 Rectangle (0) | 2023.05.27 |
[파이썬] 문제 : 문자열에서 특정 문자들로 분리하기 (0) | 2023.05.26 |
[파이썬] 문제 : 2,3,4,6를 @@*@@=@@*@@를 만족하는 조건 찾기 (0) | 2023.05.25 |
[파이썬] 1차원 데이터의 CNN(Conv1D) 딥러닝 (0) | 2023.05.24 |
댓글