Skip to content

Commit

Permalink
Mention that Gtk.Table is deprecated and move it to bottom of section
Browse files Browse the repository at this point in the history
  • Loading branch information
sebp committed Aug 3, 2012
1 parent 3e6c055 commit caff4f2
Showing 1 changed file with 65 additions and 62 deletions.
127 changes: 65 additions & 62 deletions source/layout.txt
Expand Up @@ -34,7 +34,7 @@ horizontally from left to right or right to left depending on whether
:meth:`Gtk.Box.pack_start` or :meth:`Gtk.Box.pack_end` is used.
In a vertical box, widgets are packed from top to bottom or vice versa.
You may use any combination of boxes inside or beside other boxes to create
the desired effect.
the desired effect.

Box Objects
^^^^^^^^^^^
Expand All @@ -60,10 +60,10 @@ Box Objects
widgets with reference to a particular position in a :class:`Gtk.Container`.
For a :class:`Gtk.Box`, there are two reference positions: the start
and the end of the box.
If "orientation" is :attr:`Gtk.Orientation.VERTICAL`, the start is defined
If "orientation" is :attr:`Gtk.Orientation.VERTICAL`, the start is defined
as the top of the box and the end is defined as the bottom.
If "orientation" is :attr:`Gtk.Orientation.HORIZONTAL`, the start is defined
as the left side and the end is defined as the right side.
as the left side and the end is defined as the right side.

.. method:: pack_start(child, expand, fill, padding)

Expand Down Expand Up @@ -128,6 +128,59 @@ Subsequently, we add two different buttons to the box container.
While with :meth:`Gtk.Box.pack_start` widgets are positioned from left to right,
:meth:`Gtk.Box.pack_end` positions them from right to left.

Grid
----
:class:`Gtk.Grid` is a container which arranges its child widgets in rows and
columns, but you do not need to specify the dimensions in the constructor.
Children are added using :meth:`Gtk.Grid.attach`. They can span multiple rows or
columns. It is also possible to add a child next to an existing child, using
:meth:`Gtk.Grid.attach_next_to`.

:class:`Gtk.Grid` can be used like a :class:`Gtk.Box` by just using
:meth:`Gtk.Grid.add`, which will place children next to each other in the
direction determined by the "orientation" property (defaults to
:attr:`Gtk.Orientation.HORIZONTAL`).

Grid Objects
^^^^^^^^^^^^
.. class:: Gtk.Grid

Creates a new grid widget.

.. method:: attach(child, left, top, width, height)

Adds *child* to this grid.

The position of *child* is determined by the index of the cell left to
it (*left*) and above of it (*top*). The number of 'cells' that *child*
will occupy is determined by *width* and *height*.

.. method:: attach_next_to(child, sibling, side, width, height)

Adds *child* to this grid, next to *sibling*. *side* is the side of
*sibling* that *child* is positioned next to. It can be one of

* :attr:`Gtk.PositionType.LEFT`
* :attr:`Gtk.PositionType.RIGHT`
* :attr:`Gtk.PositionType.TOP`
* :attr:`Gtk.PositionType.BOTTOM`

*width* and *height* determine the number of 'cells' that *child* will
occupy.

.. method:: add(widget)

Adds *widget* to this grid in the direction determined by the
"orientation" property.

Example
^^^^^^^

.. image:: ../images/layout_grid_example.png

.. literalinclude:: ../examples/layout_grid_example.py
:linenos:

Table
-----

Expand All @@ -143,11 +196,14 @@ of the column, and for rows, the space goes below the row.

You can also set a consistent spacing for all rows and/or columns with
:meth:`Gtk.Table.set_row_spacings` and :meth:`Gtk.Table.set_col_spacings`.
Note that with these calls, the last row and last column do not get any spacing.
Note that with these calls, the last row and last column do not get any spacing.

Table Objects
^^^^^^^^^^^^^

.. deprecated:: 3.4
Use :class:`Gtk.Grid` instead.

.. class:: Gtk.Table(rows, columns, homogeneous)

The first argument is the number of rows to make in the table, while the
Expand Down Expand Up @@ -187,17 +243,17 @@ Table Objects
bitwise ORed together to allow multiple options. These options are:

* :attr:`Gtk.AttachOptions.EXPAND`: The widget should expand to take up
any extra space in its container that has been allocated.
any extra space in its container that has been allocated.
* :attr:`Gtk.AttachOptions.FILL`: The widget will expand to use all the
room available.
* :attr:`Gtk.AttachOptions.SHRINK`: Reduce size allocated to the widget
to prevent it from moving off screen.

If omitted, *xoptions* and *yoptions* defaults to
``Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL``.

Finally, the padding arguments work just as they do for
:meth:`Gtk.Box.pack_start`.
:meth:`Gtk.Box.pack_start`.
If omitted, *xpadding* and *ypadding* defaults to ``0``.

.. method:: set_row_spacing(row, spacing)
Expand All @@ -211,11 +267,11 @@ Table Objects

.. method:: set_row_spacings(spacing)

Sets the space between every row in this table equal to *spacing*.
Sets the space between every row in this table equal to *spacing*.

.. method:: set_col_spacings(spacing)

Sets the space between every column in this table equal to *spacing*.
Sets the space between every column in this table equal to *spacing*.

Example
^^^^^^^
Expand All @@ -224,56 +280,3 @@ Example

.. literalinclude:: ../examples/layout_table_example.py
:linenos:

Grid
----
:class:`Gtk.Grid` is a container which arranges its child widgets in rows and
columns, but you do not need to specify the dimensions in the constructor.
Children are added using :meth:`Gtk.Grid.attach`. They can span multiple rows or
columns. It is also possible to add a child next to an existing child, using
:meth:`Gtk.Grid.attach_next_to`.

:class:`Gtk.Grid` can be used like a :class:`Gtk.Box` by just using
:meth:`Gtk.Grid.add`, which will place children next to each other in the
direction determined by the "orientation" property (defaults to
:attr:`Gtk.Orientation.HORIZONTAL`).

Grid Objects
^^^^^^^^^^^^
.. class:: Gtk.Grid

Creates a new grid widget.

.. method:: attach(child, left, top, width, height)

Adds *child* to this grid.

The position of *child* is determined by the index of the cell left to
it (*left*) and above of it (*top*). The number of 'cells' that *child*
will occupy is determined by *width* and *height*.

.. method:: attach_next_to(child, sibling, side, width, height)

Adds *child* to this grid, next to *sibling*. *side* is the side of
*sibling* that *child* is positioned next to. It can be one of

* :attr:`Gtk.PositionType.LEFT`
* :attr:`Gtk.PositionType.RIGHT`
* :attr:`Gtk.PositionType.TOP`
* :attr:`Gtk.PositionType.BOTTOM`

*width* and *height* determine the number of 'cells' that *child* will
occupy.

.. method:: add(widget)

Adds *widget* to this grid in the direction determined by the
"orientation" property.

Example
^^^^^^^

.. image:: ../images/layout_grid_example.png

.. literalinclude:: ../examples/layout_grid_example.py
:linenos:

0 comments on commit caff4f2

Please sign in to comment.