【发布时间】:2023-02-01 06:01:36
【问题描述】:
因此,我从阅读文档中了解到,set_halign(gtk::Align::End) 会将按钮向右对齐,但这并没有发生,它与带有 set_halign(gtk::Align::Start) 的按钮保持向左对齐。
pub fn create_widget(&self) -> impl IsA<Widget> {
let frame1 = frame::create_frame(self, "frame1");
let box1 = boxx::create_box(self, "box1");
box1.set_orientation(Orientation::Vertical);
frame1.add(&box1);
let superman_box = boxx::create_box(self, "superman box");
superman_box.set_orientation(Orientation:Horizontal);
box1.add(&superman_box);
let superman_button = button::create_text_button(self, "superman", "Superman");
superman_button.connect_clicked(move |_| {});
superman_button.set_halign(gtk::Align::Start);
superman_box.add(&superman_button);
let sessions_button = button::create_text_button(self, "sessions_button", "Sessions");
sessions_button.connect_clicked(move |_| {});
sessions_button.set_halign(gtk::Align::End);
superman_box.add(&sessions_button);
let logout_button = button::create_text_button(self, "logout_button", "Logout");
logout_button.connect_clicked(move |_| {});
logout_button.set_halign(gtk::Align::End);
superman_box.add(&logout_button);
}
【问题讨论】: