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
相关推荐
樱花树下的数学喵2 小时前
手写简易 STL string|C++ 字符串底层实现
开发语言·c++
遇码3 小时前
2026-11-01-daw-retry-banner-body
人工智能·ai·rust·数据分析·大模型·agent
IT_陈寒3 小时前
SpringBoot自动配置的坑,这次终于爬出来了
前端·人工智能·后端
jimy13 小时前
C++ 报错的 qualifiers 的意思
开发语言·c++
RainbowFish3 小时前
# RAG 与智能体记忆:从原理到工程实践 > 一篇给学习者的总结。
后端
苏三说技术3 小时前
为什么越来越多人用Arthas 4 ?
后端
ServBay4 小时前
AI 开发平台出事后,API Key 泄露要怎么办
后端·aigc·ai编程
程序员老申4 小时前
解剖 PDF 底层二进制:一行代码如何抓出假薪资流水的 3 处破绽
后端
JuiceFS4 小时前
从 Meta 的工程实践看 EB 级 AI 存储架构
人工智能·后端
数据库小学妹4 小时前
MySQL NULL陷阱:NOT IN、三值逻辑与NOT EXISTS
数据库·后端·mysql