Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gtk::Table

class Gtk::Table

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_column_spacing.

The gaps between all rows or columns can be changed by calling Gtk::Table#row_spacings= or Gtk::Table#column_spacings= respectively.

Gtk::Table#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.

Class Methods

Gtk::Table.new(rows, columns, homogeneous = false)
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 0 .. 65535.
  • rows: The number of rows the new table should have.
  • columns: The number of columns the new table should have.
  • homogeneous: If set to true, all table cells are resized to the size of the cell containing the largest widget.
  • Returns: A pointer to the the newly created table widget.

Instance Methods

resize(rows, columns)
If you need to change a table's size after it has been created, this function allows you to do so.
  • rows: The new number of rows.
  • columns: The new number of columns.
  • Returns: self
attach(child, left, right, top, bottom, xopt = Gtk::EXPAND|Gtk::FILL, yopt = Gtk::EXPAND|Gtk::FILL, xpad = 0, ypad = 0)
Adds a widget to a table. The number of 'cells' that a widget will occupy is specified by left, right, top and bottom. These each represent the leftmost, rightmost, uppermost and lowest column and row numbers of the table. (Columns and rows are indexed from zero).
  • child: The widget to add.
  • left: the column number to attach the left side of a child widget to.
  • right: the column number to attach the right side of a child widget to.
  • top: the row number to attach the left side of a child widget to.
  • bottom: the row number to attach the right side of a child widget to.
  • xopt: Used to specify the properties of the child widget when the table is resized. (GtkAttachOptions)
  • yopt: The same as xopt, except this field determines behaviour of vertical resizing. (GtkAttachOptions)
  • xpad: An integer value specifying the padding on the left and right of the widget being added to the table.
  • ypad: The amount of padding above and below the child widget.
  • Returns: self
attach_defaults(widget, left, right, top, bottom)
As there are many options associated with Gtk::Table#attach, this convenience method provides the programmer with a means to add children to a table with identical padding and expansion options.
  • widget : The child widget to add.
  • left: the column number to attach the left side of a child widget to.
  • right: the column number to attach the right side of a child widget to.
  • top: the row number to attach the left side of a child widget to.
  • bottom: the row number to attach the right side of a child widget to.
  • Returns: self
get_row_spacing(row)
Gets the amount of space between row row, and row row + 1. See Gtk::Table#set_row_spacing.
  • row: a row in the table, 0 indicates the first row
  • Returns: the row spacing
set_row_spacing(row, spacing)
Changes the space between a given table row and its surrounding rows.
  • row: row number whose spacing will be changed.
  • spacing: number of pixels that the spacing should take up.
  • Returns: self
row_spacings
Gets the amount of space between two consecutive rows.
  • Returns: the amount of space between two consecutive rows.
row_spacings=(spacing)
Sets the amount of space between two consecutive rows.
  • spacing: the amount of space between two consecutive rows.
  • Returns: spacing
set_row_spacings(spacing)
Same as Gtk::Table#row_spacing=.
  • spacing: the amount of space between two consecutive rows.
  • Returns: self
default_row_spacing
Gets the default row spacing for the table. This is the spacing that will be used for newly added rows. (See Gtk::Table#row_spacings=)
  • Returns: value the default row spacing
get_column_spacing(column)
Gets the amount of space between column col, and column col + 1. See Gtk::Table#set_column_spacing.
  • column: a column in the table, 0 indicates the first column
  • Returns: the column spacing
set_column_spacing(column, spacing)
Alters the amount of space between a given table column and the adjacent columns.
  • column: the column whose spacing should be changed.
  • spacing: number of pixels that the spacing should take up.
column_spacings
Gets the amount of space between two consecutive rows.
  • Returns: the amount of space between two consecutive rows.
column_spacings=(spacing)
Sets the amount of space between two consecutive columns.
  • spacing: the amount of space between two consecutive columns.
  • Returns: spacing
set_column_spacings(spacing)
Same as Gtk::Table#column_spacings=.
  • spacing: the amount of space between two consecutive columns.
  • Returns: self
default_column_spacing
Gets the default column spacing for the table. This is the spacing that will be used for newly added columns. (See Gtk::Table#column_spacings=)
  • Returns: value the default column spacing
homogeneous?
Returns whether the table cells are all constrained to the same width and height. (See Gtk::Table#homogenous=)
  • Returns: true if the cells are all constrained to the same size
homogeneous=(homogeneous)
Changes the homogenous property of table cells, ie. whether all cells are an equal size or not.
  • homogeneous: Set to true to ensure all table cells are the same size. Set to false if this is not your desired behaviour.
  • Returns: homogeneous
set_homogeneous(homogeneous)
Same as Gtk::Table#homogeneous=.
  • homogeneous: Set to true to ensure all table cells are the same size. Set to false if this is not your desired behaviour.
  • Returns: self
n_rows
Retrieves the number of rows in a table.
  • Returns: the number of rows in a table.
n_rows=(rows)
Sets the number of rows in a table.
  • rows: the number of rows in a table.
  • Returns: rows
set_n_rows(rows)
Same as Gtk::Table#n_rows=.
  • rows: the number of rows in a table.
  • Returns: self
n_columns
Retrieves the number of columns in a table.
  • Returns: the number of columns in a table.
n_columns=(columns)
Sets the number of columns in a table.
  • columns: the number of columns in a table.
  • Returns: columns
set_n_columns(columns)
Same as Gtk::Table#n_columns=.
  • columns: the number of columns in a table.
  • Returns: self
ref_accessible
See Atk::Implementor#ref_accessible.
add_child
See Gtk::Buildable#add_child.
construct_child
See Gtk::Buildable#construct_child.
get_internal_child
See Gtk::Buildable#get_internal_child.
name
See Gtk::Buildable#name.
name=
See Gtk::Buildable#name=.
set_buildable_property
See Gtk::Buildable#set_buildable_property.
set_name
See Gtk::Buildable#set_name.
builder_name
See Gtk::Buildable#builder_name.
builder_name=
See Gtk::Buildable#builder_name=.
set_builder_name
See Gtk::Buildable#set_builder_name.

Properties

column-spacing: Integer (Read/Write)
The amount of space between two consecutive columns
homogeneous: true or false (Read/Write)
If true this means the table cells are all the same width/height
n-columns: Integer (Read/Write)
The number of columns in the table
n-rows: Integer (Read/Write)
The number of rows in the table
row-spacing: Integer (Read/Write)
The amount of space between two consecutive rows

Child Properties

bottom-attach: Integer (Read/Write)
The row number to attach the bottom of the child to
left-attach: Integer (Read/Write)
The column number to attach the left side of the child to
right-attach: Integer (Read/Write)
The column number to attach the right side of a child widget to
top-attach: Integer (Read/Write)
The row number to attach the top of a child widget to
x-options: Gtk::AttachOptions (Read/Write)
Options specifying the horizontal behaviour of the child
x-padding: Integer (Read/Write)
Extra space to put between the child and its left and right neighbors, in pixels
y-options: Gtk::AttachOptions (Read/Write)
Options specifying the vertical behaviour of the child
y-padding: Integer (Read/Write)
Extra space to put between the child and its upper and lower neighbors, in pixels