rust gui fltk

FLTK 图形用户界面库的 Rust 绑定。

fltk crate 是一个跨平台的轻量级 GUI 库,可以静态链接以生成小型、独立且快速的 GUI 应用程序。

doc

https://www.rust-lang.org/zh-CN/learn/get-started
https://docs.rs/fltk/latest/fltk/

install

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ sudo apt install cmake git
$ cargo install fltk-fluid
$ cargo install fl2rust

app

$ mkdir rust-app
$ cd rust-app
$ cargo new app

vi Cargo.toml

[dependencies]
fltk = "^1.4"

[patch.crates-io]
fltk = { git = "https://ghproxy.net/https://github.com/fltk-rs/fltk-rs" }

vi src/main.rs

use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};

fn main() {
    let app = app::App::default();
    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
    let mut frame = Frame::new(0, 0, 400, 200, "");
    let mut but = Button::new(160, 210, 80, 40, "Click me!");
    wind.end();
    wind.show();
    but.set_callback(move |_| frame.set_label("Hello World!")); // the closure capture is mutable borrow to our button
    app.run().unwrap();
}

build

$ cargo clean
$ cargo build
$ cargo run

你可能感兴趣的:(rust,开发语言,后端)