Fork me on GitHub

egui.info

Unofficial notes about the excellent egui crate

egui-101-basic

This is a simple example with a heading, label, and button

Source

Screenshots

Screenshot

Description

The update function is the workhorse of egui. It is called up to 60 times per second to render the contents of the UI.

fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
    ctx.set_pixels_per_point(1.5);

    egui::CentralPanel::default().show(ctx, |ui| {
        ui.heading("This is a ui.heading. ");

        ui.label("This is a ui.label");

        // This literally creates the button AND checks to see if it was clicked
        if ui.button("Quit").clicked() {
            std::process::exit(0);
        };
    });
}