Beginner's First GUI In Rust

Kent West - kent.west@{that mail that swore to do no evil}

I've been wanting to get my feet wet with GUI programming using Rust, and I finally found a simple enough tool to do so; it's found at Dioxus Labs.

I'm doing this on a Debian 12 GNU/Linux Box, with Cinnamon as my Desktop.

Install Rust

Install Rust, and make sure you can compile and run a simple "Hello, World" program.

Install some dependencies:

Install the GTK+ dependencies
# apt install libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev libxdo-dev

Then create a new project:

Create a new Rust Project
$ cargo new --bin demo

(The --bin is optional; it's assumed if not given.)

Create the Program

Then edit the src/main.rs file to the following:

src/main.rs
#![allow(non_snake_case)]
// import the prelude to get access to the `rsx!` macro and the `Element` type
use dioxus::prelude::*;

fn main() {
    // launch the dioxus app in a webview
    launch(App);
}

// define a component that renders a div with the text "Hello, world!"
fn App() -> Element {
    rsx! { div { "Hello, world!" } }
}
// end of main()

Run the Program

And run the program to display a window with a "Hello, World!" message. Simple.

Run the program
$ cargo run

The Result