GLXCurses.Container module¶
-
class
GLXCurses.Container.
Container
[source]¶ Bases:
GLXCurses.Widget.Widget
GLXCurses.Container — Base class for widgets which contain other widgets
Description:
A GLXCurse user interface is constructed by nesting widgets inside widgets. Container widgets are the inner nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a GLXCurse.Window containing a GLXCurse.Frame containing a GLXCurse.Label. If you wanted an image instead of a textual label inside the frame, you might replace the GLXCurse.Label widget with a GLXCurse.Image widget.
There are two major kinds of container widgets in GLXCurses. Both are subclasses of the abstract GLXCurse.Container base class.
The first type of container widget has a single child widget and derives from GLXCurses.Bin. These containers are decorators, which add some kind of functionality to the child. For example, a GLXCurses.Button makes its child into a clickable button; a GLXCurses.Frame draws a frame around its child and a GLXCurses.Window places its child widget inside a top-level window.
The second type of container can have more than one child; its purpose is to manage layout. This means that these containers assign sizes and positions to their children. For example, a GLXCurses.HBox arranges its children in a horizontal row, and a GLXCurses.Grid arranges the widgets it contains in a two-dimensional grid.
For implementations of GLXCurses.Container the virtual method GLXCurses.Container.forall() is always required, since it’s used for drawing and other internal operations on the children. If the GLXCurses.Container implementation expect to have non internal children it’s needed to implement both GLXCurses.Container.add() and GLXCurses.Container.remove(). If the GLXCurses.Container implementation has internal children, they should be added widget.set_parent() on __init__() and removed with widget.unparent() in the GLXCurses.Widget.destroy() implementation. See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
-
border_width
¶ Set the
border_width
property valueAllowed values: <= 65535
Default value: 0
Returns: The width of the empty border outside the containers children. Return type: int
-
child
¶ Set the
child
property valueReturns: Child element Return type: GLXCurses.ChildElement or None
-
resize_mode
¶ Set the
resize_mode
property valueDefault value:
GLXC.RESIZE_PARENT
Returns: Specify how resize events are handled. Return type: str
-
add
(widget=None)[source]¶ Adds widget to container .
Typically used for simple containers such as Window, Frame, or Button;
For more complicated layout containers such as Box or Grid, this function will pick default packing parameters that may not be correct.
So consider functions such as
GLXCurses.Box.pack_start()
andGLXCurses.Grid.attach()
as an alternative toGLXCurses.Container.add()
in those cases.A widget may be added to only one container at a time; you (should not) place the same widget inside two different containers.
Parameters: widget (GLXCurses.Widget) – a widget to be placed inside container Raises: TypeError – if widget
is not a instance of GLXCurses.Widget
-
remove
(widget=None)[source]¶ Removes widget from container .
Widget must be inside container .
Note that container will own a reference to widget , and that this may be the last reference held; so removing a widget from its container can destroy that widget. If you want to use widget again, you need to add a reference to it before removing it from a container, using g_object_ref(). If you don’t want to use widget again it’s usually more efficient to simply destroy it directly using Widget.destroy() since this will remove it from the container and help break any circular reference count cycles.
Parameters: widget (GLXCurses Widget) – a current child of container Raises: TypeError – if widget is not a instance of GLXCurses.Widget
-
add_with_properties
(widget=None, properties=None)[source]¶ Adds widget to container , setting child properties at the same time. See GLXCurses.Container.add() and GLXCurses.Container.child_set() for more details.
Parameters: - widget (GLXCurses.Widget) – a widget to be placed inside container
- properties (GLXCurses.ChildProperty) – properties to set
Raises: - TypeError – if
properties
is not a GLXCurses.ChildProperty instance - TypeError – if widget is not a instance of GLXCurses.Widget
-
get_resize_mode
()[source]¶ Returns the resize mode for the container.
- Allowed value:
- GLXC.RESIZE_PARENT
- GLXC.RESIZE_QUEUE
- GLXC.RESIZE_IMMEDIATE
See also
GLXCurses.Container.set_resize_mode()
.Warning
GLXCurses.Container.get_resize_mode()
has been deprecated since version 3.12 of GTK+, if will be remove as soon of possible.Returns: the current resize mode Return type: GLXCurses.Constants
-
set_resize_mode
(resize_mode=None)[source]¶ Sets the resize mode for the container.
The resize mode of a container determines whether a resize request will be passed to the container’s parent, queued for later execution or executed immediately.
- Allowed value:
- GLXC.RESIZE_PARENT
- GLXC.RESIZE_QUEUE
- GLXC.RESIZE_IMMEDIATE
See also
Warning
GLXCurses.Container.set_resize_mode()
has been deprecated since version 3.12 of GTK+, if will be remove as soon of possible.Parameters: resize_mode (GLXCurses.Constants) – the new resize mode
-
foreachs
(callback, *callback_data)[source]¶ Invokes callback on each non-internal child of container . See GLXCurses.Container.forall() for details on what constitutes an “internal” child. For all practical purposes, this function should iterate over precisely those child widgets that were added to the container by the application with explicit add() calls.
Most applications should use GLXCurses.Container.foreachs(), rather than GLXCurses.Container.forall().
Parameters: - callback – a callback.
- callback_data – callback user __area_data
-
get_path_for_child
(child=None)[source]¶ Returns a newly created widget path representing all the widget hierarchy from the toplevel down to and including child .
Returns: A newly created WidgetPath
-
get_focus_vadjustment
()[source]¶ Retrieves the vertical focus adjustment for the container. See
Container.set_focus_vadjustment()
.Returns: the vertical focus adjustment, or :py:__area_data:None if none has been set. Return type: Adjustment()
or :py:__area_data:None
-
set_focus_vadjustment
(adjustment=None)[source]¶ Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This function sets the vertical alignment. See scrolled_window_get_vadjustment() for a typical way of obtaining the adjustment and
Container.set_focus_hadjustment()
for setting the horizontal adjustment.The adjustments have to be in character units and in the same coordinate system as the allocation for immediate children of the container.
Parameters: adjustment ( Adjustment()
or :py:__area_data:None) – an adjustment which should be adjusted when the focus is moved among the descendants ofcontainer
Raises: TypeError – if adjustment
is not aAdjustment()
-
get_focus_hadjustment
()[source]¶ Retrieves the horizontal focus adjustment for the container. See
Container.set_focus_hadjustment()
.Returns: the horizontal focus adjustment, or :py:__area_data:None if none has been set. Return type: Adjustment()
or :py:__area_data:None
-
set_focus_hadjustment
(adjustment)[source]¶ Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This function sets the horizontal alignment. See scrolled_window_get_hadjustment() for a typical way of obtaining the adjustment and
Container.set_focus_vadjustment()
for setting the vertical adjustment.The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
Parameters: adjustment ( Adjustment()
or :py:__area_data:None) – an adjustment which should be adjusted when the focus is moved among the descendants ofcontainer
Raises: TypeError – if adjustment
is not aAdjustment()
-
child_type
(container)[source]¶ Returns the type of the children supported by the container.
Note that this may return
None
to indicate that no more children can be added, e.g. for a Paned which already has two children.Note that this may return
-1
to indicatecontainer
is not foundParameters: container – Returns: the type of children Return type: str , None or -1 Raises: TypeError – if child
is not a GLXCurses type as tested byglxc_type()
-
child_set
(child, properties=None)[source]¶ Sets one or more child properties for child and container .
Parameters: - child (A GLXCurses.Widget) – a GLXCurses.Widget which is a child of container
- properties (GLXCurses.ChildProperty) – properties to set
Raises: - TypeError – if
child
is not a GLXCurses type as tested byglxc_type()
- TypeError – if
properties
is not a dict type
-
child_get
(child)[source]¶ Gets the values of one or more child properties for child and container .
Parameters: child (A GLXCurses object) – a widget which is a child of container Returns: properties of the child or None if child not found Return type: dict or None Raises: TypeError – if child
is not a GLXCurses type as tested byglxc_type()
-
child_set_property
(child, property_name=None, value=None)[source]¶ Sets a child property for child and container .
Parameters: - child (a GLXCures.Widget) – a GLXCurses.Widget which is a child of GLXCurses.Container
- property_name (str) – the name of the property to set
- value (everything except None) – the value to set the property to
Raises: - TypeError – if
child
is not a GLXCurses type as tested byglxc_type()
- TypeError – if
property_name
is not str type - TypeError – if
value
is None type
-
child_get_property
(child, property_name=None)[source]¶ Gets the value of a child property for child and container .
Parameters: - child (a GLXCures Object) – a widget which is a child of container
- property_name (str) – the name of the property to set
Raises: - TypeError – if
child
is not a GLXCurses type as tested byglxc_type()
- TypeError – if
property_name
is not str type
-
get_border_width
()[source]¶ Retrieves the border width of the container.
See GLXCurses.Container.set_border_width().
Returns: the current border width Return type: int
-
set_border_width
(border_width=0)[source]¶ Sets the border width of the container.
The border width of a container is the amount of space to leave around the outside of the container. The only exception to this is GLXCurses.Window; because toplevel windows can’t leave space outside, they leave the space inside. The border is added on all sides of the container. To add space to only one side, use a specific “margin” property on the child widget, for example “margin-top”.
border_width have valid values are in the range 0-65535 chars and will be clamp to value.
Parameters: border_width (int) – amount of blank space to leave outside the container. Raises: TypeError – When border_width is not a int
-