Re: the art of packing



Mark Mackenzie <markm student unsw edu au> writes:
> i) Is it a 'bad thing' to set x &| y widths of various widgets if I
> am having trouble getting them to behave as I expect them?

Yes, somewhat.  Set them manually if you have to, but those occasions
should generally be rare.  You shouldn't need to do it for the example
below, for instance.

>                   +------------+
> +frm--+   Label   |  but.text  |
> | rb1 |           +------------+    +------------+
> | rb2 |                             |  but.text  |
> +-----+           +------------+    +------------+
>           Label   |  but.text  |
>                   +------------+
> 
> +window
>       `vbox
>         +hbox1 (a box above box of interest)
>         +hbox2
>         | +frame1 (vbox with 2 radio buttons)
>         | +table1
>         | | +label1 "Input file: " (Added " " for alignment. Is this ok?)
>         | | +label2 "Output file:"
>         | | +button1
>         | | `button2
>         | `vbox2   (oops - is this the right way to do it?)
>         |   `button3
>         `hbox3 (another box below box of interest)
> 
> Am I on the right track? 

Pretty much.  The extra space in label1 isn't very pretty -- better to set
the GTK_FILL flag when adding it to the table, and then you can use
gtk_misc_set_alignment() to play with the text position.  That way, the
layout will still be correct regardless of font, theme, translations, etc.

> Is vbox2 superfluous?

It's OK, though as an aside, if you are using a box just to position one
widget, a GtkAlignment is more flexible than a box.

> Buttons1&2 will bring up file dialog boxen and the label will be
> changed to the selected filename(without path). Is it ok to set
> horizontal width?

I suppose that will work, if you don't mind your window changing size
depending on the length of the filename.  You might want to consider
alternative ways to display the name another way (a GtkEntry, with the
button beside it, perhaps?)

Cheers,
Gary.
-- 
  Gary Wong    Consultant, Dependable Distributed Computing, AT&T Shannon Labs
        gtw research att com            http://www.cs.arizona.edu/~gary/




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