vispy.scene.widgets.widget module#

class vispy.scene.widgets.widget.Widget(pos=(0, 0), size=(10, 10), border_color=None, border_width=1, bgcolor=None, padding=0, margin=0, **kwargs)#

Bases: Compound

A widget takes up a rectangular space, intended for use in a 2D pixel coordinate frame.

The widget is positioned using the transform attribute (as any node), and its extent (size) is kept as a separate property.

Parameters:
pos(x, y)

A 2-element tuple to specify the top left corner of the widget.

size(w, h)

A 2-element tuple to spicify the size of the widget.

border_colorcolor

The color of the border.

border_widthfloat

The width of the border line in pixels.

bgcolorcolor

The background color.

paddingint

The amount of padding in the widget (i.e. the space reserved between the contents and the border).

marginint

The margin to keep outside the widget’s border.

add_grid(*args, **kwargs)#

Create a new Grid and add it as a child widget.

All arguments are given to Grid().

add_view(*args, **kwargs)#

Create a new ViewBox and add it as a child widget.

All arguments are given to ViewBox().

add_widget(widget)#

Add a Widget as a managed child of this Widget.

The child will be automatically positioned and sized to fill the entire space inside this Widget (unless _update_child_widgets is redefined).

Parameters:
widgetinstance of Widget

The widget to add.

Returns:
widgetinstance of Widget

The widget.

property bgcolor#

The background color of the Widget.

property border_color#

The color of the border.

property height#

The actual height of the widget

property height_max#

The maximum height of the widget

property height_min#

The minimum height of the widget

property inner_rect#

The rectangular area inside the margin, border, and padding.

Generally widgets should avoid drawing or placing sub-widgets outside this rectangle.

property margin#
property padding#
property picking#

Boolean that determines whether this node (and its children) are drawn in picking mode.

property pos#
property rect#
remove_widget(widget)#

Remove a Widget as a managed child of this Widget.

Parameters:
widgetinstance of Widget

The widget to remove.

property size#

The size (w, h) of this widget.

If the widget is a child of another widget, then its size is assigned automatically by its parent.

property stretch#

Stretch factors (w, h) used when determining how much space to allocate to this widget in a layout.

If either stretch factor is None, then it will be assigned when the widget is added to a layout based on the number of columns or rows it occupies.

property width#

The actual width of this widget

property width_max#

The maximum width the widget can have

property width_min#

The minimum width the widget can have