Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

eGUI Window

  • CentralPanel
  • NativeOptions
  • run_simple_native
cargo new egui-window
cd egui-window
cargo add eframe

This will make Cargo.toml look like this:

[package]
name = "egui-window"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
eframe = "0.24"

The code is here:

use eframe::egui;

fn main() -> Result<(), eframe::Error> {
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
        ..Default::default()
    };

    eframe::run_simple_native("Rust Maven egui App", options, move |ctx, _frame| {
        egui::CentralPanel::default().show(ctx, |_ui| {});
    })
}

{% embed include file="src/examples/egui/egui-window/screenshot.png)

When you click on the X to close the window, you might get lots of warnings like this:

warning: queue 0x7fa398000ca0 destroyed while proxies still attached:

This was reported here.