Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.09 KB

adding_widgets.md

File metadata and controls

46 lines (34 loc) · 1.09 KB

Adding Widgets

Use column! and row! to group multiple widgets such as text and button.

use iced::{
    widget::{button, column, row, text},
    Sandbox, Settings,
};

fn main() -> iced::Result {
    MyApp::run(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> {
        column![
            text("Yes or no?"),
            row![
                button("Yes"),
                button("No"),
            ],
        ].into()
    }
}

Adding widgets

➡️ Next: Changing Displaying Content

📘 Back: Table of contents