RE: Problems with aligning and spacing widgets
- From: "Vallone, Anthony" <anthony vallone lmco com>
- To: Sandra Derbring <sandra derbring gmail com>, gtk-list gnome org
- Subject: RE: Problems with aligning and spacing widgets
- Date: Thu, 08 May 2008 10:35:32 -0400
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.
-Anthony
Hello,
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!
Sandra
#Make a box
self.box
= gtk.HBox(homogeneous=False)
self.mainbox.pack_start(self.box)
self.box.show()
#2 boxes inside box
self.picbox = gtk.VBox()
self.box.pack_start(self.picbox)
self.picbox.show()
self.textbox =
gtk.VBox()
self.box.pack_start(self.textbox)
self.textbox.show()
#Creates the
texts and buttons
testbox =
gtk.VBox()
buttonbox =
gtk.VBox()
#textframe =
gtk.Frame(filename)
textlabel =
gtk.Label(textstr)
testbox.pack_start(textlabel)
altstr =
""
chosenpos = gtk.CheckButton(pos)
chosenpos.set_active(True)
#testbox.pack_start(chosenpos)
buttonbox.pack_start(chosenpos)
buttontuple = (word, pos, chosenpos)
self.buttonlist.append(buttontuple)
chosenpos.show()
for alt in alts:
cbutton =
gtk.CheckButton(alt.strip())
#testbox.pack_start(cbutton)
buttonbox.pack_start(cbutton)
buttontuple = (word, alt.strip(),
cbutton)
self.buttonlist.append(buttontuple)
cbutton.show()
altstr = altstr + " and " + alt
if len(alts) > 1:
altbutton = gtk.CheckButton(altstr)
#testbox.pack_start(altbutton)
buttonbox.pack_start(altbutton)
buttontuple = (word, altstr, altbutton)
self.buttonlist.append(buttontuple)
altbutton.show()
#If the chosen pos gives wrong meaning
and no alts are correct:
crobutton =
gtk.CheckButton("Fel - ska till CRO")
#testbox.pack_start(crobutton)
buttonbox.pack_start(crobutton)
buttontuple = (word, "CRO", crobutton)
self.buttonlist.append(buttontuple)
crobutton.show()
#textframe.add(testbox)
#textframe.add(buttonbox)
textlabel.show()
#textframe.show()
testbox.show()
buttonbox.show()
#self.textbox.pack_start(textframe)
self.textbox.pack_start(testbox)
self.textbox.pack_start(buttonbox)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]