gtkD GUI design

FG home at fgda.pl
Thu Jan 31 05:32:44 PST 2013


On 2013-01-31 13:35, SaltySugar wrote:
> Thanks, setBorderWidth() is working but button's size isn't changing.

I don't have a working gtk environment to test it, but try this:
(maybe hBox2 isn't even needed and you could vBox.add(algn1);)


     import gtk.MainWindow;
     import gtk.Label;
     import gtk.Button;
     import gtk.VBox;
     import gtk.HBox;
     import gtk.Entry;
     import gtk.Main;
     import gtk.Alignment;

     class Application : MainWindow
     {
         this()
         {
             super("GtkD App");
             setDefaultSize(200, 200);

             HBox hBox = new HBox(false, 3);
             HBox hBox1 = new HBox(false, 3);
             VBox vBox = new VBox(false, 5);

             // Alignment(xalign, yalign, xscale, yscale)
             // xscale = 0 stops the child from stretching in X axis
             Alignment algn1 = new Alignment(0.5, 0, 0, 0);
             HBox hBox2 = new HBox(false, 3);

             Button btnLog = new Button("LOGIN --->");
             Label lblNick = new Label("User: ");
             Entry txtNick = new Entry();
             Label lblPass = new Label("Password: ");
             Entry txtPass = new Entry();

             btnLog.setSizeRequest(70, 30);
             vBox.packStart(hBox, true, true, 3);
             vBox.packStart(hBox1, true, true, 3);
             vBox.setBorderWidth(8);

             hBox.add (lblNick);
             hBox.add (txtNick);
             hBox1.add (lblPass);
             hBox1.add (txtPass);

             algn1.add (btnLog);
             hBox2.add (algn1);
             vBox.add (hBox2);

             add(vBox);
             showAll();
         }
     }
     void main(string[] args)
     {
         Main.init(args);
         new Application();
         Main.run();
     }



More information about the Digitalmars-d-learn mailing list