Nikolaus Rath wrote:
>>> | - vbox.pack_start(self.make_shot_box(), False)
>>> | + vbox.pack_start(self.make_shot_box(), False, False)
>>>
>>> Isn't the third parameter to pack_start ignored anyway if the second one
>>> is False?
>> No! the prototype is :
>> def pack_start(child, expand=True, fill=True, padding=0)
>> So to set 'fill' to False you need at least 3 arguments.
>
> I don't understand.
>
> http://www.pygtk.org/pygtk2tutorial/sec-DetailsOfBoxes.html:
>
> "The fill argument to the pack methods control whether the extra space
> is allocated to the objects themselves (True), or as extra padding in
> the box around these objects (False). It only has an effect if the
> expand argument is also True".
>
> In the above line you set expand to False, so you don't have to provide
> a value for fill, IMO.
>
That appears to be the fact. But I still prefer to specify both
'expand' and 'fill'.
>>> | def make_shot_box(self):
>>> | - box = gtk.HBox(True, 10)
>>> | + box = gtk.HBox(False, 10)
>>>
>>>
>>> This seems to get rid of the spacing between the label and spin
>>> button -- but why?
>> It doesn't. It just sets the spacing of the widgets.
>> The code "box = gtk.HBox(spacing = 10)" would do the same thing.
>
> The spacing is the same in both versions, you changed the 'homogenous'
> parameter.
>
No! The default is for 'homogenous' is False. So technically you
don't need to specify it.
>>> | + box.pack_start(gtk.Label(''), True, True, 0)
>>>
>>> What is this for?
>> It (and its mate further along) are there to use up the available
>> space in 'box' to make the other widgets as small as possible, and to
>> thereby cause them to be centralized.
>
> Uh, I think I see. So the only way to center something in a box is to
> add an "empty" element on both sides with expand=True?
It is the only way I have found.
>
>> As another thing, there is an easier way to create the buttons in the
>> make_button_box() function.
>> for (name,number) in [
>> ('INIT',1),
>> ('PULSE ON',2),
>> ('STORE',3),
>> ('ANALYSIS',4)] :
>> button = gtk.Button(name)
>> button.connect('clicked', self.blub, number)
>> box.pack_start(button, True, True)
>
> The buttons of course call different functions in the real code, this
> was just to simplify the example.
>
Ok! but you could put in a function like.
for (name,function) in [('INIT',self.on_init_clicked),
('PULSE ON',self.on_pulse_clicked)] :
button = gtk.Button(name)
button.connect('clicked', function)
box.pack_start(button, True, True)
Its just a coding preference, instead of have many pieces of code
almost the same.
>
> Best,
>
> -Nikolaus
>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/