Gtk.Table

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Table Gtk.Table Gtk.Container->Gtk.Table Gtk.Widget->Gtk.Container

Subclasses:

None

Methods

Inherited:

Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)

Structs:

Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new (rows, columns, homogeneous)

attach (child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)

attach_defaults (widget, left_attach, right_attach, top_attach, bottom_attach)

get_col_spacing (column)

get_default_col_spacing ()

get_default_row_spacing ()

get_homogeneous ()

get_row_spacing (row)

get_size ()

resize (rows, columns)

set_col_spacing (column, spacing)

set_col_spacings (spacing)

set_homogeneous (homogeneous)

set_row_spacing (row, spacing)

set_row_spacings (spacing)

Virtual Methods

Inherited:

Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

Properties

Inherited:

Gtk.Container (3), Gtk.Widget (39)

Name

Type

Flags

Short Description

column-spacing

int

r/w

The amount of space between two consecutive columns

homogeneous

bool

r/w

If True, the table cells are all the same width/height

n-columns

int

r/w

The number of columns in the table

n-rows

int

r/w

The number of rows in the table

row-spacing

int

r/w

The amount of space between two consecutive rows

Child Properties

Name

Type

Default

Flags

Short Description

bottom-attach

int

1

r/w

The row number to attach the bottom of the child to

left-attach

int

0

r/w

The column number to attach the left side of the child to

right-attach

int

1

r/w

The column number to attach the right side of a child widget to

top-attach

int

0

r/w

The row number to attach the top of a child widget to

x-options

Gtk.AttachOptions

Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL

r/w

Options specifying the horizontal behaviour of the child

x-padding

int

0

r/w

Extra space to put between the child and its left and right neighbors, in pixels

y-options

Gtk.AttachOptions

Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL

r/w

Options specifying the vertical behaviour of the child

y-padding

int

0

r/w

Extra space to put between the child and its upper and lower neighbors, in pixels

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.Table(*args, **kwargs)
Bases:

Gtk.Container

Abstract:

No

Structure:

Gtk.TableClass

The Gtk.Table functions allow the programmer to arrange widgets in rows and columns, making it easy to align many widgets next to each other, horizontally and vertically.

Tables are created with a call to Gtk.Table.new(), the size of which can later be changed with Gtk.Table.resize().

Widgets can be added to a table using Gtk.Table.attach() or the more convenient (but slightly less flexible) Gtk.Table.attach_defaults().

To alter the space next to a specific row, use Gtk.Table.set_row_spacing(), and for a column, Gtk.Table.set_col_spacing(). The gaps between all rows or columns can be changed by calling Gtk.Table.set_row_spacings() or Gtk.Table.set_col_spacings() respectively. Note that spacing is added between the children, while padding added by Gtk.Table.attach() is added on either side of the widget it belongs to.

Gtk.Table.set_homogeneous(), can be used to set whether all cells in the table will resize themselves to the size of the largest widget in the table.

Gtk.Table has been deprecated. Use Gtk.Grid instead. It provides the same capabilities as Gtk.Table for arranging widgets in a rectangular grid, but does support height-for-width geometry management.

classmethod new(rows, columns, homogeneous)[source]
Parameters:
  • rows (int) – The number of rows the new table should have.

  • columns (int) – The number of columns the new table should have.

  • homogeneous (bool) – If set to True, all table cells are resized to the size of the cell containing the largest widget.

Returns:

A pointer to the newly created table widget.

Return type:

Gtk.Widget

Used to create a new table widget. An initial size must be given by specifying how many rows and columns the table should have, although this can be changed later with Gtk.Table.resize(). rows and columns must both be in the range 1 .. 65535. For historical reasons, 0 is accepted as well and is silently interpreted as 1.

Deprecated since version 3.4: Use Gtk.Grid.new().

attach(child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)[source]
Parameters:
  • child (Gtk.Widget) – The widget to add.

  • left_attach (int) – the column number to attach the left side of a child widget to.

  • right_attach (int) – the column number to attach the right side of a child widget to.

  • top_attach (int) – the row number to attach the top of a child widget to.

  • bottom_attach (int) – the row number to attach the bottom of a child widget to.

  • xoptions (Gtk.AttachOptions) – Used to specify the properties of the child widget when the table is resized.

  • yoptions (Gtk.AttachOptions) – The same as xoptions, except this field determines behaviour of vertical resizing.

  • xpadding (int) – An integer value specifying the padding on the left and right of the widget being added to the table.

  • ypadding (int) – The amount of padding above and below the child widget.

Adds a widget to a table. The number of “cells” that a widget will occupy is specified by left_attach, right_attach, top_attach and bottom_attach. These each represent the leftmost, rightmost, uppermost and lowest column and row numbers of the table. (Columns and rows are indexed from zero).

To make a button occupy the lower right cell of a 2x2 table, use

gtk_table_attach (table, button,
1, 2, // left, right attach
1, 2, // top, bottom attach
xoptions, yoptions,
xpadding, ypadding);

If you want to make the button span the entire bottom row, use left_attach == 0 and right_attach = 2 instead.

Deprecated since version 3.4: Use Gtk.Grid.attach() with Gtk.Grid. Note that the attach arguments differ between those two functions.

attach_defaults(widget, left_attach, right_attach, top_attach, bottom_attach)[source]
Parameters:
  • widget (Gtk.Widget) – The child widget to add.

  • left_attach (int) – The column number to attach the left side of the child widget to.

  • right_attach (int) – The column number to attach the right side of the child widget to.

  • top_attach (int) – The row number to attach the top of the child widget to.

  • bottom_attach (int) – The row number to attach the bottom of the child widget to.

As there are many options associated with Gtk.Table.attach(), this convenience function provides the programmer with a means to add children to a table with identical padding and expansion options. The values used for the Gtk.AttachOptions are GTK_EXPAND | GTK_FILL, and the padding is set to 0.

Deprecated since version 3.4: Use Gtk.Grid.attach() with Gtk.Grid. Note that the attach arguments differ between those two functions.

get_col_spacing(column)[source]
Parameters:

column (int) – a column in the table, 0 indicates the first column

Returns:

the column spacing

Return type:

int

Gets the amount of space between column col, and column col + 1. See Gtk.Table.set_col_spacing().

Deprecated since version 3.4: Gtk.Grid does not offer a replacement for this functionality.

get_default_col_spacing()[source]
Returns:

the default column spacing

Return type:

int

Gets the default column spacing for the table. This is the spacing that will be used for newly added columns. (See Gtk.Table.set_col_spacings())

Deprecated since version 3.4: Use Gtk.Grid.get_column_spacing() with Gtk.Grid.

get_default_row_spacing()[source]
Returns:

the default row spacing

Return type:

int

Gets the default row spacing for the table. This is the spacing that will be used for newly added rows. (See Gtk.Table.set_row_spacings())

Deprecated since version 3.4: Use Gtk.Grid.get_row_spacing() with Gtk.Grid.

get_homogeneous()[source]
Returns:

True if the cells are all constrained to the same size

Return type:

bool

Returns whether the table cells are all constrained to the same width and height. (See Gtk.Table.set_homogeneous ())

Deprecated since version 3.4: Use Gtk.Grid.get_row_homogeneous() and Gtk.Grid.get_column_homogeneous() with Gtk.Grid.

get_row_spacing(row)[source]
Parameters:

row (int) – a row in the table, 0 indicates the first row

Returns:

the row spacing

Return type:

int

Gets the amount of space between row row, and row row + 1. See Gtk.Table.set_row_spacing().

Deprecated since version 3.4: Gtk.Grid does not offer a replacement for this functionality.

get_size()[source]
Returns:

rows:

return location for the number of rows, or None

columns:

return location for the number of columns, or None

Return type:

(rows: int, columns: int)

Gets the number of rows and columns in the table.

New in version 2.22.

Deprecated since version 3.4: Gtk.Grid does not expose the number of columns and rows.

resize(rows, columns)[source]
Parameters:
  • rows (int) – The new number of rows.

  • columns (int) – The new number of columns.

If you need to change a table’s size after it has been created, this function allows you to do so.

Deprecated since version 3.4: Gtk.Grid resizes automatically.

set_col_spacing(column, spacing)[source]
Parameters:
  • column (int) – the column whose spacing should be changed.

  • spacing (int) – number of pixels that the spacing should take up.

Alters the amount of space between a given table column and the following column.

Deprecated since version 3.4: Use Gtk.Widget.set_margin_start() and Gtk.Widget.set_margin_end() on the widgets contained in the row if you need this functionality. Gtk.Grid does not support per-row spacing.

set_col_spacings(spacing)[source]
Parameters:

spacing (int) – the number of pixels of space to place between every column in the table.

Sets the space between every column in self equal to spacing.

Deprecated since version 3.4: Use Gtk.Grid.set_column_spacing() with Gtk.Grid.

set_homogeneous(homogeneous)[source]
Parameters:

homogeneous (bool) – Set to True to ensure all table cells are the same size. Set to False if this is not your desired behaviour.

Changes the homogenous property of table cells, ie. whether all cells are an equal size or not.

Deprecated since version 3.4: Use Gtk.Grid.set_row_homogeneous() and Gtk.Grid.set_column_homogeneous() with Gtk.Grid.

set_row_spacing(row, spacing)[source]
Parameters:
  • row (int) – row number whose spacing will be changed.

  • spacing (int) – number of pixels that the spacing should take up.

Changes the space between a given table row and the subsequent row.

Deprecated since version 3.4: Use Gtk.Widget.set_margin_top() and Gtk.Widget.set_margin_bottom() on the widgets contained in the row if you need this functionality. Gtk.Grid does not support per-row spacing.

set_row_spacings(spacing)[source]
Parameters:

spacing (int) – the number of pixels of space to place between every row in the table.

Sets the space between every row in self equal to spacing.

Deprecated since version 3.4: Use Gtk.Grid.set_row_spacing() with Gtk.Grid.

Property Details

Gtk.Table.props.column_spacing
Name:

column-spacing

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The amount of space between two consecutive columns

Gtk.Table.props.homogeneous
Name:

homogeneous

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

If True, the table cells are all the same width/height

Gtk.Table.props.n_columns
Name:

n-columns

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE

The number of columns in the table

Gtk.Table.props.n_rows
Name:

n-rows

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE

The number of rows in the table

Gtk.Table.props.row_spacing
Name:

row-spacing

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

The amount of space between two consecutive rows