views:

40

answers:

1

EDIT: Click here for the code.

So I'm experimenting with interface building with MonoDevelop (version 2.4). I'm trying to get used to the Gtk concept of "containers within containers". I created a vbox with two... er... boxes, put a menu on the top box, and a table on the bottom one. I set the table to have two column and five rows. On the top four rows, I put a label in the left and an entry in the right. On the bottom right cell I put a button. It looks like this:

GUIBlah Application

Here's the things I'm struggling with:

1) How do I get the table's columns NOT to be of equal width? Amusingly, when I added just the labels, and hadn't added the entry boxes yet, the left column used up only the space needed for the labels. Now it's 50/50 and it won't budge.

2) How do I get the labels to be right-aligned, so the final ":" in their texts gets nicely aligned and close to the entry boxes? I set the "Justify" property of the labels to "Right" and was seemingly ignored.

3) The action code for the "Open" and "Close" actions under the "File" menu consist on displaying a modal message box with an OK button. But pressing the OK button doesn't dismiss the message box, only closing the message box window does. The code is:

(new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok,
                  "Open Action")).Show();
+3  A: 

1) Set at least of one the Entry widgets to "expand" and "fill" horizontally.

2) Set the label's Xalign property to 1.0. Justify controls layout of wrapped text, Xalign/Yalign controls the position of the whole block within the label's area.

3) You should Destroy() the dialog after you're done with it. Alternatively you can Hide() it and re-use it. You should also look into using the dialog's Run() method - typically something like:

var dialog = new FooDialog(...);
try {
    dialog.Show();
    var response = (ResponseType) dialog.Run ();
    if (response == ResponseType.Ok) {
        //do stuff
    }
} finally {
    dialog.Destroy ();
}
mhutch
Tip #3 worked. :) Tips #1 and #2 had zero effect. If you want to take a closer look, here's the code: http://users.vialink.com.br/jcastro/GUIBlah.tgz
JCCyC
Re. #2, your labels need to be "fill" but not "expand". See the following screencast: http://is.gd/ePzhZ - you want the labels for fill all space allocated, and the entries to fill all space allocated and expand into any available space.
mhutch
That worked! And I solved #1 too... the table had the "Homogeneous" property set! Now it's the way I wanted. Thanks!
JCCyC