On 26-02-2021 23:14, Dejan Lekic wrote:
I've made a tiny test GtkD DUB project (with GtkD 3.9.0 as
dependency) to make a minimal reproducible example of a problem I am
having in a larger project. Apparently Box is not expanding the middle
Widget (in this case Button) to take all available space. Am I doing
something wrong?
import gtk.MainWindow; import gtk.Label; import gtk.Button; import gtk.Main; import gtk.Box; void main(string[] args) { Main.init(args); MainWindow window = new MainWindow("Pack test"); Box box = new Box(Orientation.VERTICAL, 0); Label topLabel = new Label("Top"); box.add(topLabel); box.packStart(topLabel, false, false, 0); Button bigButton = new Button("Big button"); box.add(bigButton); box.packStart(bigButton, true, true, 0); Label bottomLabel = new Label("Bottom"); box.add(bottomLabel); box.packStart(bottomLabel, false, false, 0); window.add(box); window.setDefaultSize(800, 600); window.showAll(); Main.run(); }
add is does the same as packStart but with defaults, so it messes things
up if you call both. Only using packStart should work:
import gtk.MainWindow;
import gtk.Label;
import gtk.Button;
import gtk.Main;
import gtk.Box;
void main(string[] args) {
Main.init(args);
MainWindow window = new MainWindow("Pack test");
Box box = new Box(Orientation.VERTICAL, 0);
Label topLabel = new Label("Top");
//box.add(topLabel);
box.packStart(topLabel, false, false, 0);
Button bigButton = new Button("Big button");
//box.add(bigButton);
box.packStart(bigButton, true, true, 0);
Label bottomLabel = new Label("Bottom");
//box.add(bottomLabel);
box.packStart(bottomLabel, false, false, 0);
window.add(box);
window.setDefaultSize(800, 600);
window.showAll();
Main.run();
}