RE: Problems with aligning and spacing widgets

When you want vertical or horizontal alignment, use GtkVBox or GtkHBox.  For both vertical and horizontal alignment, use GtkTable. 
Also, you may find it useful to design GUIs with glade.  Even if you don't use it for XML or code gen, it will quickly point you in the right direction for layout choices.

From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] On Behalf Of Sandra Derbring
Sent: Thursday, May 08, 2008 5:19 AM
To: gtk-list gnome org
Subject: Problems with aligning and spacing widgets


I am working on a GUI that should present a picture representing a word, the word and information about it. I have two main problems. The first one is: I have created two vertical boxes, positioned next to each other inside a horizontal box. In the right one, I present all pictures, each in one box. In the other one, I present the information to the picture. My problem is that the pictureboxes and the corresponding textboxes don't get the same size (depending on how much text and how big the pic is). I'd like them to correspond so you right away can see which pic belongs to which text. I tried at first to make a lot of horizontal boxes with picbox + textbox in it, which solved the problem - but the different hboxes were not the same size. How do I do to make boxes the same size, both inside the same box and in another box?
My other problem: In the textboxes, I write a little piece of text, and then I have some checkbuttons. The number of checkbuttons is different from box to box (between one and five). The spacing between the buttons is different and I'd like them to be at the same distance from each other in all boxes. I guess this has to do with them being different in number and also depending on the text's size. Can I adjust this in some way?

Here comes the code. Maybe it is a bit long, but I hope there is everything you need to understand it. Before, I had a frame for each box, I removed it because I thought it had something to do with the problem, but it didn't. Before, the text and the buttons were packed into the same box (testbox) and this was added to the frame, which was added to the main box.

Thankful for all help!

        #Make a box = gtk.HBox(homogeneous=False)
        #2 boxes inside box
        self.picbox = gtk.VBox()
        self.textbox = gtk.VBox()

       #Creates the texts and buttons
        testbox = gtk.VBox()
        buttonbox = gtk.VBox()
        #textframe = gtk.Frame(filename)
        textlabel = gtk.Label(textstr)
        altstr = ""
        chosenpos = gtk.CheckButton(pos)
        buttontuple = (word, pos, chosenpos)
        for alt in alts:
            cbutton = gtk.CheckButton(alt.strip())
            buttontuple = (word, alt.strip(), cbutton)
            altstr = altstr + " and " + alt
        if len(alts) > 1:
            altbutton = gtk.CheckButton(altstr)
            buttontuple = (word, altstr, altbutton)
        #If the chosen pos gives wrong meaning and no alts are correct:
        crobutton = gtk.CheckButton("Fel - ska till CRO")
        buttontuple = (word, "CRO", crobutton)

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