Gtk.Grid¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Orientable (2) | 
|---|---|
| Structs: | Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5) | 
| class | new() | 
| attach(child, left, top, width, height) | |
| attach_next_to(child, sibling, side, width, height) | |
| get_baseline_row() | |
| get_child_at(left, top) | |
| get_column_homogeneous() | |
| get_column_spacing() | |
| get_row_baseline_position(row) | |
| get_row_homogeneous() | |
| get_row_spacing() | |
| insert_column(position) | |
| insert_next_to(sibling, side) | |
| insert_row(position) | |
| remove_column(position) | |
| remove_row(position) | |
| set_baseline_row(row) | |
| set_column_homogeneous(homogeneous) | |
| set_column_spacing(spacing) | |
| set_row_baseline_position(row, pos) | |
| set_row_homogeneous(homogeneous) | |
| set_row_spacing(spacing) | 
Virtual Methods¶
| Inherited: | Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10) | 
|---|
Properties¶
| Inherited: | Gtk.Container (3), Gtk.Widget (39), Gtk.Orientable (1) | 
|---|
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| baseline-row | int | r/w/en | The row to align the to the baseline when valign is Gtk.Align.BASELINE | 
| column-homogeneous | bool | r/w/en | If True, the columns are all the same width | 
| column-spacing | int | r/w/en | The amount of space between two consecutive columns | 
| row-homogeneous | bool | r/w/en | If True, the rows are all the same height | 
| row-spacing | int | r/w/en | The amount of space between two consecutive rows | 
Child Properties¶
| Name | Type | Default | Flags | Short Description | 
|---|---|---|---|---|
| height | int | 1 | r/w | The number of rows that a child spans | 
| left-attach | int | 0 | r/w | The column number to attach the left side of the child to | 
| top-attach | int | 0 | r/w | The row number to attach the top side of a child widget to | 
| width | int | 1 | r/w | The number of columns that a child spans | 
Style Properties¶
| Inherited: | Gtk.Widget (17) | 
|---|
Signals¶
| Inherited: | Gtk.Container (4), Gtk.Widget (69), GObject.Object (1) | 
|---|
Fields¶
| Inherited: | Gtk.Container (4), Gtk.Widget (69), GObject.Object (1) | 
|---|
| Name | Type | Access | Description | 
|---|---|---|---|
| container | Gtk.Container | r | 
Class Details¶
- 
class Gtk.Grid(**kwargs)¶
- Bases: - Gtk.Container,- Gtk.Orientable- Abstract: - No - Structure: - Gtk.GridClass- Gtk.Gridis a container which arranges its child widgets in rows and columns, with arbitrary positions and horizontal/vertical spans.- Children are added using - Gtk.Grid.attach(). They can span multiple rows or columns. It is also possible to add a child next to an existing child, using- Gtk.Grid.attach_next_to(). The behaviour of- Gtk.Gridwhen several children occupy the same grid cell is undefined.- Gtk.Gridcan be used like a- Gtk.Boxby just using- Gtk.Container.add(), which will place children next to each other in the direction determined by the- Gtk.Orientable- :orientationproperty. However, if all you want is a single row or column, then- Gtk.Boxis the preferred widget.- CSS nodes
 - Gtk.Griduses a single CSS node with name grid.- 
classmethod new()[source]¶
- Returns: - the new - Gtk.Grid- Return type: - Gtk.Widget- Creates a new grid widget. 
 - 
attach(child, left, top, width, height)[source]¶
- Parameters: - child (Gtk.Widget) – the widget to add
- left (int) – the column number to attach the left side of child to
- top (int) – the row number to attach the top side of child to
- width (int) – the number of columns that child will span
- height (int) – the number of rows that child will span
 - Adds a widget to the grid. - The position of child is determined by left and top. The number of “cells” that child will occupy is determined by width and height. 
- child (
 - 
attach_next_to(child, sibling, side, width, height)[source]¶
- Parameters: - child (Gtk.Widget) – the widget to add
- sibling (Gtk.WidgetorNone) – the child of self that child will be placed next to, orNoneto place child at the beginning or end
- side (Gtk.PositionType) – the side of sibling that child is positioned next to
- width (int) – the number of columns that child will span
- height (int) – the number of rows that child will span
 - Adds a widget to the grid. - The widget is placed next to sibling, on the side determined by side. When sibling is - None, the widget is placed in row (for left or right placement) or column 0 (for top or bottom placement), at the end indicated by side.- Attaching widgets labeled [1], [2], [3] with sibling == - Noneand side ==- Gtk.PositionType.LEFTyields a layout of ‘3 [2]’[1].
- child (
 - 
get_baseline_row()[source]¶
- Returns: - the row index defining the global baseline - Return type: - int- Returns which row defines the global baseline of self. - New in version 3.10. 
 - 
get_child_at(left, top)[source]¶
- Parameters: - Returns: - the child at the given position, or - None- Return type: - Gtk.Widgetor- None- Gets the child of self whose area covers the grid cell whose upper left corner is at left, top. - New in version 3.2. 
 - 
get_column_homogeneous()[source]¶
- Returns: - whether all columns of self have the same width. - Return type: - bool- Returns whether all columns of self have the same width. 
 - 
get_column_spacing()[source]¶
- Returns: - the column spacing of self - Return type: - int- Returns the amount of space between the columns of self. 
 - 
get_row_baseline_position(row)[source]¶
- Parameters: - row ( - int) – a row index- Returns: - the baseline position of row - Return type: - Gtk.BaselinePosition- Returns the baseline position of row as set by - Gtk.Grid.set_row_baseline_position() or the default value- Gtk.BaselinePosition.CENTER.- New in version 3.10. 
 - 
get_row_homogeneous()[source]¶
- Returns: - whether all rows of self have the same height. - Return type: - bool- Returns whether all rows of self have the same height. 
 - 
get_row_spacing()[source]¶
- Returns: - the row spacing of self - Return type: - int- Returns the amount of space between the rows of self. 
 - 
insert_column(position)[source]¶
- Parameters: - position ( - int) – the position to insert the column at- Inserts a column at the specified position. - Children which are attached at or to the right of this position are moved one column to the right. Children which span across this position are grown to span the new column. - New in version 3.2. 
 - 
insert_next_to(sibling, side)[source]¶
- Parameters: - sibling (Gtk.Widget) – the child of self that the new row or column will be placed next to
- side (Gtk.PositionType) – the side of sibling that child is positioned next to
 - Inserts a row or column at the specified position. - The new row or column is placed next to sibling, on the side determined by side. If side is - Gtk.PositionType.TOPor- Gtk.PositionType.BOTTOM, a row is inserted. If side is- Gtk.PositionType.LEFTof- Gtk.PositionType.RIGHT, a column is inserted.- New in version 3.2. 
- sibling (
 - 
insert_row(position)[source]¶
- Parameters: - position ( - int) – the position to insert the row at- Inserts a row at the specified position. - Children which are attached at or below this position are moved one row down. Children which span across this position are grown to span the new row. - New in version 3.2. 
 - 
remove_column(position)[source]¶
- Parameters: - position ( - int) – the position of the column to remove- Removes a column from the grid. - Children that are placed in this column are removed, spanning children that overlap this column have their width reduced by one, and children after the column are moved to the left. - New in version 3.10. 
 - 
remove_row(position)[source]¶
- Parameters: - position ( - int) – the position of the row to remove- Removes a row from the grid. - Children that are placed in this row are removed, spanning children that overlap this row have their height reduced by one, and children below the row are moved up. - New in version 3.10. 
 - 
set_baseline_row(row)[source]¶
- Parameters: - row ( - int) – the row index- Sets which row defines the global baseline for the entire grid. Each row in the grid can have its own local baseline, but only one of those is global, meaning it will be the baseline in the parent of the self. - New in version 3.10. 
 - 
set_column_homogeneous(homogeneous)[source]¶
- Parameters: - homogeneous ( - bool) –- Trueto make columns homogeneous- Sets whether all columns of self will have the same width. 
 - 
set_column_spacing(spacing)[source]¶
- Parameters: - spacing ( - int) – the amount of space to insert between columns- Sets the amount of space between columns of self. 
 - 
set_row_baseline_position(row, pos)[source]¶
- Parameters: - row (int) – a row index
- pos (Gtk.BaselinePosition) – aGtk.BaselinePosition
 - Sets how the baseline should be positioned on row of the grid, in case that row is assigned more space than is requested. - New in version 3.10. 
- row (
 
Property Details¶
- 
Gtk.Grid.props.baseline_row¶
- Name: - baseline-row- Type: - int- Default Value: - 0- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- The row to align the to the baseline when valign is - Gtk.Align.BASELINE
- 
Gtk.Grid.props.column_homogeneous¶
- Name: - column-homogeneous- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- If - True, the columns are all the same width
- 
Gtk.Grid.props.column_spacing¶
- Name: - column-spacing- Type: - int- Default Value: - 0- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- The amount of space between two consecutive columns 
- 
Gtk.Grid.props.row_homogeneous¶
- Name: - row-homogeneous- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- If - True, the rows are all the same height
- 
Gtk.Grid.props.row_spacing¶
- Name: - row-spacing- Type: - int- Default Value: - 0- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- The amount of space between two consecutive rows