Skip to content

Instantly share code, notes, and snippets.

@aganzha
Last active November 25, 2023 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aganzha/d396f0d0d982f1d18839046dee3ef693 to your computer and use it in GitHub Desktop.
Save aganzha/d396f0d0d982f1d18839046dee3ef693 to your computer and use it in GitHub Desktop.
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();
}
@aganzha
Copy link
Author

aganzha commented Nov 25, 2023

Screencast.from.2023-11-25.14-04-53.webm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment