Widget: Base of every widget implementation.

Widget: Base of every widget implementation.

pymt.ui.widgets.widget.getWidgetById(widget_id)

Get a widget by ID

class pymt.ui.widgets.widget.MTWidget(**kwargs)

Bases: pymt.event.EventDispatcher

Global base for any multitouch widget. Implement event for mouse, object, touch and animation.

Event are dispatched through widget only if it’s visible.

Parameters :
pos : list, default is (0, 0)

Position of widget, in (x, y) format

x : int, default is None

X position of widget

y : int, default is None

Y position of widget

size : list, default is (100, 100)

Size of widget, in (width, height) format

width : int, default is None

width position of widget

height : int, default is None

height position of widget

visible : bool, default is True

Visibility of widget

draw_children : bool, default is True

Indicate if children will be draw, or not

style : dict, default to {}

Add inline CSS

cls : str, default is ‘’

CSS class of this widget

Events :
on_update ()

Used to update the widget and his children.

on_draw ()

Used to draw the widget and his children.

on_touch_down (Touch touch)

Fired when a blob appear

on_touch_move (Touch touch)

Fired when a blob is moving

on_touch_up (Touch touch)

Fired when a blob disappear

on_resize (float width, float height)

Fired when widget is resized

on_parent_resize (float width, float height)

Fired when parent widget is resized

add_widget(w, front=True)

Add a widget in the children list.

apply_css(styles)

Called at __init__ time to applied css attribute in current class.

bring_to_front()

Remove it from wherever it is and add it back at the top

children

List of children (SafeList)

cls

Get/Set the class of the widget (used for CSS, can be a string or a list of string

do(animation)

Apply/Start animations on the widgets.

Parameters :
animation : Animation Object

Animation object with properties to be animateds “,”

draw()

Handle the draw of widget. Derivate this method to draw your widget.

draw_children

If False, childrens are not drawed. (deprecated)

get_parent_layout()

Return the parent layout of widget

get_parent_window()

Return the parent window of widget

get_root_window()

Return the root window of widget

hide()

Hide the widget

id

str: id of widget

parent

MTWidget: parent of widget. Fired on_parent event when set

reload_css()

Called when css want to be reloaded from scratch

remove_widget(w)

Remove a widget from the children list

show()

Show the widget

size_hint

size_hint is used by layouts to determine size behaviour during layout

style

Dictionnary that contains the widget style

to_local(x, y, relative=False)

Transform parent coordinate to local coordinate

Parameters :
relative: bool, default to False

Change to True is you want to translate a coordinate to a relative coordinate from widget.

to_parent(x, y, relative=False)

Transform local coordinate to parent coordinate

Parameters :
relative: bool, default to False

Change to True is you want to translate relative position from widget to his parent.

to_widget(x, y, relative=False)

Return the coordinate from window to local widget

to_window(x, y, initial=True, relative=False)

Transform local coordinate to window coordinate

visible

True if the widget is visible. If False, the events on_draw,on_touch_down, on_touch_move, on_touch_up are not dispatched.

Previous topic

SVG widget: widget that display an svg image

Next topic

XML widget: parse xml and create his children

This Page