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

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-21 04:40:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-21 04:40:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-21 04:40:01       82 阅读
  4. Python语言-面向对象

    2024-02-21 04:40:01       91 阅读

热门阅读

  1. Rabbitmq的几种模式的总结

    2024-02-21 04:40:01       52 阅读
  2. 学习数据接构和算法的第11天

    2024-02-21 04:40:01       62 阅读
  3. 【Git】切换分支【2024年2月19日】

    2024-02-21 04:40:01       48 阅读
  4. Spring设计模式之工厂模式创建Bean对象

    2024-02-21 04:40:01       51 阅读
  5. eNSP学习——RSTP基础配置

    2024-02-21 04:40:01       47 阅读
  6. 如何使用阿里云OSS进行前端直传

    2024-02-21 04:40:01       44 阅读
  7. 【Git】基本概念和使用方式

    2024-02-21 04:40:01       43 阅读
  8. 如何使用 FFmpeg 批量转换文件夹内的所有文件

    2024-02-21 04:40:01       46 阅读
  9. 低代码开发:学校低成本数字化转型的新引擎

    2024-02-21 04:40:01       69 阅读
  10. ubuntu上安装docker

    2024-02-21 04:40:01       51 阅读