The gtk.Box class is an abstract class describing the functionality of a container in which widgets are located in a rectangular area. gtk.HBox and gtk.VBox widgets are resultant from it.
Child widgets in gtk.Hbox are arranged horizontally in the same row. On the other hand, child widgets of gtk.VBox are organized vertically in the same column.
gtk.Box class uses the following constructor –
The identical property is set to true by default. As an outcome, all child widgets are given equal allocation.
gtk.Box uses the packing tool to place child widgets in it with reference to a particular position, either with reference to start or end. pack_start() method places widgets from start to end. On the contrary, the pack_end() method puts widgets from end to start. Otherwise, you can use the add() method which is similar to pack_start().
The following methods are available for gtk.HBox as well as gtk.VBox −
This method adds child to the box, packed with reference to the start of box –
The following are the parameters −
child − This is the widget object to be added to box
expand − This is set to True if child is to be given extra space in the box. Extra space is divided between all child widgets.
fill − If True, extra space will be allocated to child. Otherwise, this parameter is used as padding.
padding − This is the space in pixels between widgets in the box.
This adds child to the box, packed with reference to the end of the box.
The resulting are the parameters −
The function that sets the number of pixels to place between the children of the box is set_spacing (spacing)
The method add (widget) is inherited from the gtk.Container class. It adds widget to the container. This method can be used instead of the pack_start() method.
In the instance specified below, the toplevel window covers a vertical box (gtk.VBox object box). It in turn has a VBox object vb and HBox object hb. In the upper box, a label, an entry widget and a button are located vertically. In the lower box, another set of label, entry and button are placed vertically.
Observe the resulting code –
The above code will produce the following output –
PyGTK Related Interview Questions
|Python Interview Questions||PHP Interview Questions|
|Ruby on Rails Interview Questions||Ubuntu Certified Professional Interview Questions|
|Django Interview Questions||GNU Image Manipulation Program(GIMP) Interview Questions|
|TurboGears Interview Questions||Lisp programming Interview Questions|
|wxPython Interview Questions||Basic C Interview Questions|
|Python Automation Testing Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.