Last active
November 25, 2023 12:12
-
-
Save aganzha/d396f0d0d982f1d18839046dee3ef693 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use gtk::prelude::*; | |
use gtk::{glib, Application, ApplicationWindow, HeaderBar, Box, Orientation, Button, FlowBox, Label}; | |
const APP_ID: &str = "BoxSizing"; | |
fn main() -> glib::ExitCode { | |
let app = Application::builder().application_id(APP_ID).build(); | |
app.connect_activate(build_ui); | |
app.run() | |
} | |
fn build_ui(app: &Application) { | |
let window = ApplicationWindow::new(app); | |
window.set_default_size(640, 480); | |
let vbox = Box::new(Orientation::Vertical, 0); | |
let btn = Button::new(); | |
btn.set_label("Add child to flowbox"); | |
let flow = FlowBox::new(); | |
vbox.append(&btn); | |
vbox.append(&flow); | |
btn.connect_clicked(move |b| { | |
let bx = Box::new(Orientation::Vertical, 0); | |
let b = Button::new(); | |
b.set_label("child"); | |
bx.append(&b); | |
flow.append(&bx); | |
}); | |
window.set_child(Some(&vbox)); | |
window.present(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screencast.from.2023-11-25.14-04-53.webm