Replies: 1 comment
-
Hi! //Initalize the `NativeOptions` struct
let native_options = eframe::NativeOptions {
//Set the viewport field
viewport: ViewportBuilder {
//Set the icon field
icon: Some(std::sync::Arc::new(egui::IconData {
rgba: image::load_from_memory(include_bytes!("../../path/to/image.png"))
.unwrap()
.to_rgba8()
.to_vec(),
width: 1024,
height: 1024,
})),
//Set the rest of the fields to the `Default` value
..Default::default()
},
//Set the rest of the fields to the `Default` value
..Default::default()
};
//Create eframe window
eframe::run_native("My egui App", native_options, Box::new(|cc| Ok(Box::new(MyEguiApp::new(cc))))); If you wanted to set the application icon runtime, from the application you can use the //This is the update function of your egui application / eframe window.
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
//Set icon image
if ui.button("Change Icon").clicked() {
ctx.send_viewport_cmd(ViewportCommand::Icon(
Some(std::sync::Arc::new(egui::IconData {
rgba: image::load_from_memory(include_bytes!("../../path/to/image.png"))
.unwrap()
.to_rgba8()
.to_vec(),
width: 1024,
height: 1024,
}))
))
}
//Reset icon image
if ui.button("Reset Icon").clicked() {
ctx.send_viewport_cmd(ViewportCommand::Icon(
None
))
}
} This is how I set the Icon in my app, but there are other ways to do it if this one doesn't suit your needs. :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to set the logo of the program running in the bottom menu bar?
Beta Was this translation helpful? Give feedback.
All reactions