The easy way to make a Rust app with a GUI
Go to file
Emil Ernerfeldt f5c35169a7 Add favicon
2021-12-28 21:29:26 +01:00
.github/workflows Add libssl-dev to apt-get install 2021-08-20 14:37:33 +02:00
docs Add favicon 2021-12-28 21:29:26 +01:00
src Rename to eframe_template 2021-10-18 20:17:48 +02:00
.gitignore Initial commit 2020-12-19 21:52:39 +01:00
build_web.sh Correctly determine the target directory when project inside workspace (#28) 2021-12-28 20:48:11 +01:00
Cargo.lock Update eframe and egui to 0.15.0 2021-10-24 16:23:10 +02:00
Cargo.toml Update eframe and egui to 0.15.0 2021-10-24 16:23:10 +02:00
check.sh Update to egui/eframe 0.12.0 2021-05-10 18:40:49 +02:00
README.md Add links to egui demo app, egui docs and tutorial video in README.md 2021-12-28 21:27:26 +01:00
setup_web.sh Update to egui/eframe 0.10.0 2021-02-28 20:18:19 +01:00
start_server.sh Update to egui/eframe 0.10.0 2021-02-28 20:18:19 +01:00

eframe template

dependency status Build Status

This is a template repo for eframe, a framework for writing apps using egui.

The goal is for this to be the simplest way to get started writing a GUI app in Rust.

You can compile your app natively or for the web, and share it using Github Pages.

Getting started

Start by clicking "Use this template" at https://github.com/emilk/eframe_template/ or follow these instructions.

src/app.rs contains a simple example app. This is just to give some inspiration - most of it can be removed if you like.

Make sure you are using the latest version of stable rust by running rustup update.

The official egui docs are at https://docs.rs/egui. If you prefer watching a video introduction, check out https://www.youtube.com/watch?v=NtUkr_z7l84. For inspiration, check out the the egui web demo and follow the links in it to its source code.

Testing locally

cargo run --release

On Linux you need to first run:

sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev jq

On Fedora Rawhide you need to run:

dnf install clang clang-devel clang-tools-extra speech-dispatcher-devel libxkbcommon-devel pkg-config openssl-devel jq

Compiling for the web

You can compile your app to WASM and publish it as a web page. For this you need to set up some tools. There are a few simple scripts that help you with this:

./setup_web.sh
./build_web.sh
./start_server.sh
open http://127.0.0.1:8080/
  • setup_web.sh installs the tools required to build for web
  • build_web.sh compiles your code to wasm and puts it in the docs/ folder (see below)
  • start_server.sh starts a local HTTP server so you can test before you publish
  • Open http://127.0.0.1:8080/ in a web browser to view

The finished web app is found in the docs/ folder (this is so that you can easily share it with GitHub Pages). It consists of three files:

  • index.html: A few lines of HTML, CSS and JS that loads your app. You need to edit this (once) to replace eframe_template with the name of your crate!
  • your_crate_bg.wasm: What the Rust code compiles to.
  • your_crate.js: Auto-generated binding between Rust and JS.

You can test the template app at https://emilk.github.io/eframe_template/.

Updating egui

As of 2021, egui is in active development with frequent releases with breaking changes. eframe_template will be updated in lock-step to always use the latest version of egui.