[Gtk-sharp-list] Left-justified text in a label
Ben Motmans
Ben Motmans <ben.motmans@gmail.com>
Tue, 30 Nov 2004 08:36:24 +0100
Alignment alignment = new Alignment(1.0f, 0.5f, 0.0f, 0.0f);
alignment.Add(new Label("H: left, V: center"));
the first parameter is for horizontal alignment
0.0f = left
0.5f = center
1.0f = right
the second parameter is for vertical alignment
0.0f = top
0.5f = center
1.0f = bottom
On Mon, 29 Nov 2004 21:57:36 -0500, Daniel Morgan
<danielmorgan@verizon.net> wrote:
> How do you left-justify text in a Gtk Label?
>
> No matter what I try, nothing seems to work. It is hell-bent on being
> centered.
>
> I have a screenshot of the Dialog.
>
> http://img22.exs.cx/my.php?loc=img22&image=login_screen.png
>
> // sample code
> dialog = new Dialog ();
>
> dialog.AllowGrow = true;
> dialog.Title = "Login";
> dialog.BorderWidth = 3;
> dialog.VBox.BorderWidth = 5;
> dialog.HasSeparator = false;
>
> Frame frame = new Frame ("Connection");
>
> Table table = new Table (7, 5, false);
> table.ColumnSpacing = 4;
> table.RowSpacing = 4;
> Label label = null;
>
> label = new Label ("_Provider");
> label.Layout.Alignment = Pango.Alignment.Left;
> table.Attach (label, 0, 1, 0, 1);
> providerOptionMenu = CreateProviderOptionMenu();
> table.Attach (providerOptionMenu, 1, 5, 0, 1);
>
> label = new Label ("_Connection String");
> label.Layout.Alignment = Pango.Alignment.Left;
> table.Attach (label, 0, 1, 1, 2);
> connection_entry = new Entry ();
> connection_entry.Changed += new EventHandler (OnConnectionEntryChanged);
> table.Attach (connection_entry, 1, 5, 1, 2);
>
> label = new Label ("_Server");
> label.Layout.Alignment = Pango.Alignment.Left;
> table.Attach (label, 0, 1, 2, 3);
> server_entry = new Entry ();
> server_entry.Changed += new EventHandler (OnParameterChanged);
> table.Attach (server_entry, 1, 5, 2, 3);
>
> // [...]
>
> table.Show();
> frame.Add (table);
>
> dialog.VBox.PackStart (frame, false, false, 10);
>
> Frame appSettingFrame = new Frame ("App Settings");
> appSettingFrame.Add (grid);
> dialog.VBox.PackStart (appSettingFrame, true, true, 10);
>
> Button button = null;
> button = new Button (Stock.Ok);
> button.Clicked += new EventHandler (Connect_Action);
> button.CanDefault = true;
> dialog.ActionArea.PackStart (button, true, true, 0);
> button.GrabDefault ();
>
> button = new Button (Stock.Cancel);
> button.Clicked += new EventHandler (Dialog_Cancel);
> dialog.ActionArea.PackStart (button, true, true, 0);
> dialog.Modal = true;
> dialog.SetDefaultSize (500, 500);
>
> statusBar = new Statusbar ();
> statusBar.HasResizeGrip = false;
> dialog.VBox.PackEnd (statusBar, false, false, 0);
>
> SetStatusBarText ("Ready!");
>
> dialog.ShowAll ();
>
> _______________________________________________
> Gtk-sharp-list maillist - Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>