Widgets

Display

class Header(text='Header', level=2, center=False, **kwargs)[source]

Widget to create a header.

Parameters:
  • text (str, optional) – Text of the header. Defaults to Header.
  • level (int, optional) – Level of the header. 1 to 6 only. Defaults to 2.
  • center (bool, optional) – Wether to put this header in the middle or not. Defaults to False.
class Title(*args, **kwargs)[source]

Widget to create a title.

A title is a Header with level 1.

class SubHeader(*args, **kwargs)[source]

Widget to create a sub-header.

A sub-header is a Header with level 3.

class Markdown(content='', **kwargs)[source]

A general widget to write Markdown.

Parameters:content (str, optional) – Markdown content. Defaults to empty string.

Interactivity

class Input(label=None, *args, **kwargs)[source]

Widget to create an input.

Parameters:
  • type (str, optional) – Type of the input. Defaults to number.
  • placeholder (str, placeholder) – Placeholder for the input. If None, no placeholder is used. Defaults to None.
  • label (str) – Label to give to the Widget.
class Button(text='Button', primary=False, onclick=None, **kwargs)[source]

Widget to create a button.

Parameters:
  • text (str, optional) – Text of the button. Defaults to Button.
  • primary (bool, optional) – Wether this button is primary or not. Defaults to False.
  • onclick (Ajax, optional) – Ajax request to call if the button is clicked. If None, nothing happend on click. Defaults to None.

Base

class Widget(cls=None)[source]

Base class for all Widgets.

jquery_fn

The name of the JQuery function to use to get the value of the widget from the HTML page. Defaults to text.

Type:str
cls

List of CSS classes to apply to this widget.

Type:list of str
Parameters:cls (str or list of str, optional) – Class(es) to add to the Widget. Can be a single class (str) or several classes (list of str). If None is given, no additional class is added. Defaults to None.
add_css_class(attr)[source]

Utils method to add the class attribute in the given dictionary. This dictionary can then be used in dominate.

Parameters:attr (dict) – The attributes dictionary to be used in dominate tag class.
ajax()[source]

Method to get the Ajax request (if any) of the widget. Or None if there is no Ajax call for this widget.

Returns:Ajax request. None if there is no Ajax request.
Return type:Ajax
get()[source]

Method to get the current value of the widget.

Note

This method should be overwritten.

Returns:Current value of the widget.
Return type:object
get_str()[source]

Method to get the current value of the widget, as a string.

Returns:Current value of the widget.
Return type:str
html()[source]

Method to get the dominate HTML of the widget. This HTML needs to be rendered.

Note

This method should be overwritten.

Returns:HTML document corresponding to the widget.
Return type:dominate.document
set(x)[source]

Method to set the current value of the widget.

Note

This method should be overwritten.

Parameters:x (str) – Value of the widget to set.
class WideWidget(wide=False, *args, **kwargs)[source]

Class for Widgets that can be wide.

Parameters:wide (bool, optional) – If set to True, the widget will take all the available width. Defaults to False.