www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - GtkD Dialog layout

reply Vitaly Livshic <vitaly_himki mail.ru> writes:
Good day.

I need simple Dialog with two buttons and some fields:

public class ActivationDialog : Dialog
{
     private Entry codeEntry;

     this(Window parent)
     {
         StockID[] buttons = [ StockID.OK, StockID.CANCEL ];
         ResponseType[] responses = [ GtkResponseType.OK, 
GtkResponseType.CANCEL ];
         super("Some header", parent, GtkDialogFlags.MODAL, 
buttons, responses);

         auto box = new Grid;
         box.setColumnHomogeneous(false);
         box.setRowHomogeneous(true);
         box.setRowSpacing(3);
         box.setColumnSpacing(5);
         box.setBorderWidth(8);

         auto label = new Label("Some Text: ");
         box.attach(label, 0, 0, 1, 1);
         label = new Label("shiche tralala.com");
         box.attach(label, 1, 0, 1, 1);
         label = new Label("Enter number");
         box.attach(label, 0, 1, 1, 1);
         codeEntry = new Entry;
         box.attach(codeEntry, 1, 1, 1, 1);

         getContentArea.packStart(box, true, true, 0);
     }
}

  Compiles fine, no warnings, but I see only two buttons. GTK 
shows no warnings. I replace 'packStart' with add but it no 
effect too.

  How to add Grid to dialog properly?
May 14 2019
parent reply number <putimalitze gmx.de> writes:
On Wednesday, 15 May 2019 at 06:35:15 UTC, Vitaly Livshic wrote:
  Compiles fine, no warnings, but I see only two buttons. GTK 
 shows no warnings. I replace 'packStart' with add but it no 
 effect too.

  How to add Grid to dialog properly?
I don't know dwt, but as a plain gtk program in works fine here. I see the buttons, the labels and the entry. Though I get a gtk warning "Can't set a parent on a toplevel widget". ``` import std.stdio; import gtk.Main; import gtk.Window; import gtk.MainWindow; import gtk.Label; import gtk.Widget; import gtk.Dialog; import gtk.Entry; import gtk.Grid; void main(string[] args) { Main.init(args); MainWindow window = new MainWindow("title"); window.setSizeRequest(400, 200); ActivationDialog dialog = new ActivationDialog(window); window.add(dialog); window.showAll(); Main.run(); } // main() public class ActivationDialog : Dialog { private Entry codeEntry; this(Window parent) { StockID[] buttons = [StockID.OK, StockID.CANCEL]; ResponseType[] responses = [GtkResponseType.OK, GtkResponseType.CANCEL]; super("Some header", parent, GtkDialogFlags.MODAL, buttons, responses); auto box = new Grid; box.setColumnHomogeneous(false); box.setRowHomogeneous(true); box.setRowSpacing(3); box.setColumnSpacing(5); box.setBorderWidth(8); auto label = new Label("Some Text: "); box.attach(label, 0, 0, 1, 1); label = new Label("shiche tralala.com"); box.attach(label, 1, 0, 1, 1); label = new Label("Enter number"); box.attach(label, 0, 1, 1, 1); codeEntry = new Entry; box.attach(codeEntry, 1, 1, 1, 1); getContentArea.packStart(box, true, true, 0); } } ```
May 14 2019
parent Vitaly Livshic <vitaly_himki mail.ru> writes:
Thanks, number. I shall think.
May 15 2019