-
I need to add various buttons/text on start-up based and what was read from an ini file. |
Beta Was this translation helpful? Give feedback.
Answered by
Vadoola
Jun 6, 2024
Replies: 1 comment 2 replies
-
You can create the buttons with a import { AboutSlint, Button, VerticalBox } from "std-widgets.slint";
export component Demo {
in property <[string]> buttons: ["Ok", "Cancel", "Foo", "Bar"];
callback button-clicked(int);
button-clicked(idx) => { debug("Button \{idx} was clicked") }
preferred-height: 300px;
VerticalBox {
alignment: end;
HorizontalLayout {
alignment: center;
for btn[index] in buttons: Button {
text: btn;
clicked => { button-clicked(index); }
}
}
}
} And you can et the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What @ogoffart suggested is exactly what I'm doing in my program and it works well. My application is themeable and the theme selection buttons are determined at runtime based on the theme files found on disk.
If you want to look at my code for a more detailed example feel free: https://github.com/Vadoola/Tomotroid
Relevant Sections:
let settings = settings::load_settings();
let theme_model: Rc<VecModel<JsonTheme>> = Rc::new(VecModel::from(themes));
window.global::<ThemeCallbacks>().set_themes(ModelRc::from(theme_model.clone()));
.on_theme_changed()
callback (search …