Re: Widget Alignment




Ratcliffe, Jeffrey (Peters) wrote:
Hi!

I'm struggling with widget alignment. Running the attached code (apologies for
its length), I don't understand why the Device and Paper size labels don't
line up with the left hand side of the window, or indeed why the two
radiobuttons are not exactly aligned.

Any help appreciated!

You've packed everything with "expand" and "fill" true, which means that the
available space is divided up among the widgets whether they need it or not.

For the "Device" and "Paper Size" labels, their internal alignment is
centered, so the excess space is spread on either side, resulting in the left
edges not aligning.

The problem with the radiobuttons is essentially the same.

You have a couple of choices:

*  Use "expand" and "fill" as false for all hbox packing.  The widgets will
pack to the left edge, but the right edge will be ragged.

*  Explicitly set the internal alignment of the labels for left, like
"$labeld->set_alignment(0.0, 0.5)".  This doesn't change the amount of
leftover space, so you may want also to pack the labels with expand and fill
false, but the comboboxes with expand and fill true.

*  Use SizeGroups to ensure things line up.

*  Use a Table instead of VBox of HBoxes.

*  A combination of all of the above.


Just play around with the packing options until you understand what's going on.



-- 
muppet <scott at asofyet dot org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]