tauri-egui
is a Tauri plugin for using the egui library
in a Tauri application via glutin
. egui
is a pure Rust GUI library that runs natively, recommended by the Tauri team for secure contexts such as password and secret interfaces.
```rust use tauri::Manager; use tauri_egui::{eframe, egui, EguiPluginBuilder, EguiPluginHandle};
struct LoginApp {
password: String,
on_submit: Box
impl LoginApp {
fn new
impl eframe::App for LoginApp { fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) { let LoginApp { password, onsubmit, } = self; egui::CentralPanel::default().show(ctx, |ui| { ui.label("Enter your password"); let textfield = ui.addsized( [ui.availablewidth(), 24.], egui::TextEdit::singleline(password).password(true), ); let button = ui.button("Submit"); if (textfield.lostfocus() && ui.input().keypressed(egui::Key::Enter)) || button.clicked() { if onsubmit(password) { frame.close(); } } }); } }
fn main() {
tauri::Builder::default()
.setup(|app| {
app.wryplugin(EguiPluginBuilder::new(app.handle()));
let eguihandle = app.state::
let native_options = eframe::NativeOptions {
drag_and_drop_support: true,
initial_window_size: Some([1280.0, 1024.0].into()),
..Default::default()
};
let _window = egui_handle
.create_window(
"native-window".to_string(),
Box::new(|cc| Box::new(LoginApp::new(cc, |pwd| pwd == "tauriisawesome"))),
"Login".into(),
native_options,
)
.unwrap();
Ok(())
})
.run(tauri::generate_context!("examples/demo/tauri.conf.json"))
.expect("error while building tauri application");
} ```
tauri-egui is following Semantic Versioning 2.0.
Code: (c) 2019 - 2022 - The Tauri Programme within The Commons Conservancy.
MIT or MIT/Apache 2.0 where applicable.