We can use window::Settings to change the properties of the window (such as position and size) when we call run of a Sandbox or Application. Developers might be interested in reading the document of window::Settings for other properties.
use iced::{window, Point, Sandbox, Settings, Size};
fn main() -> iced::Result {
MyApp::run(Settings {
window: window::Settings {
size: Size {
width: 70.,
height: 30.,
},
position: window::Position::Specific(Point { x: 50., y: 60. }),
..window::Settings::default()
},
..Settings::default()
})
}
struct MyApp;
impl Sandbox for MyApp {
type Message = ();
fn new() -> Self {
Self
}
fn title(&self) -> String {
String::from("My App")
}
fn update(&mut self, _message: Self::Message) {}
fn view(&self) -> iced::Element<Self::Message> {
"Hello".into()
}
}
➡️ Next: Changing The Window Dynamically
📘 Back: Table of contents