remi package

Submodules

remi.gui module

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class remi.gui.AsciiContainer(*args, **kwargs)[source]

Bases: Container

append(widget, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

set_from_asciiart(asciipattern, gap_horizontal=0, gap_vertical=0)[source]
asciipattern (str): a multiline string representing the layout
widget1 |
widget1 |
widget2 | widget3 |

gap_horizontal (int): a percent value gap_vertical (int): a percent value

set_widget_layout(widget_key)[source]
widget_layout_map = None
class remi.gui.BODY(*args, **kwargs)[source]

Bases: Container

EVENT_ONERROR = 'onerror'
EVENT_ONLOAD = 'onload'
EVENT_ONONLINE = 'ononline'
EVENT_ONPAGEHIDE = 'onpagehide'
EVENT_ONPAGESHOW = 'onpageshow'
EVENT_ONRESIZE = 'onresize'
onload()[source]

Called when page gets loaded.

ononline()[source]
onpagehide()[source]
onpageshow(width, height)[source]
onresize(width, height)[source]
class remi.gui.Button(text='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

The Button widget. Have to be used in conjunction with its event onclick. Use Widget.onclick.connect in order to register the listener.

class remi.gui.CheckBox(checked=False, user_data='', **kwargs)[source]

Bases: Input

check box widget useful as numeric input field implements the onchange event.

get_value()[source]
Return type:

bool

onchange(value)[source]
set_value(checked)[source]
class remi.gui.CheckBoxLabel(label='checkbox', checked=False, user_data='', **kwargs)[source]

Bases: HBox

get_text()[source]
onchange(widget, value)[source]
set_text(t)[source]
property text
class remi.gui.ClassEventConnector(event_source_instance, event_name, event_method_bound)[source]

Bases: object

This class allows to manage the events. Decorating a method with decorate_event decorator The method gets the __is_event flag. At runtime, the methods that has this flag gets replaced by a ClassEventConnector. This class overloads the __call__ method, where the event method is called, and after that the listener method is called too.

callback = None
do(callback, *userdata, **kwuserdata)[source]

The callback and userdata gets stored, and if there is some javascript to add the js code is appended as attribute for the event source

kwuserdata = None
userdata = None
class remi.gui.ColorPicker(default_value='#995500', **kwargs)[source]

Bases: Input

class remi.gui.Container(children=None, *args, **kwargs)[source]

Bases: Widget

Container can be used as generic container. You can add children by the append(value, key) function. Container can be arranged in absolute positioning (assigning style[‘top’] and style[‘left’] attributes to the children or in a simple auto-alignment. You can decide the horizontal or vertical arrangement by the function set_layout_orientation(layout_orientation) passing as parameter Container.LAYOUT_HORIZONTAL or Container.LAYOUT_VERTICAL.

Tips: In html, it is a DIV tag The self.type attribute specifies the HTML tag representation The self.attributes[] attribute specifies the HTML attributes like ‘style’ ‘class’ ‘id’ The self.style[] attribute specifies the CSS style content like ‘font’ ‘color’. It will be packed together with ‘self.attributes’.

LAYOUT_HORIZONTAL = True
LAYOUT_VERTICAL = False
append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

set_layout_orientation(layout_orientation)[source]

For the generic Container, this function allows to setup the children arrangement.

Parameters:

layout_orientation (Container.LAYOUT_HORIZONTAL or Container.LAYOUT_VERTICAL) –

exception remi.gui.CssStyleError[source]

Bases: Exception

Raised when (a combination of) settings will result in invalid/improper CSS

class remi.gui.Datalist(options=None, *args, **kwargs)[source]

Bases: Container

append(options, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

class remi.gui.DatalistItem(text='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

item widget for the DropDown

get_value()[source]
set_value(text)[source]
class remi.gui.Date(default_value='2015-04-13', **kwargs)[source]

Bases: Input

class remi.gui.DropDown(*args, **kwargs)[source]

Bases: Container

Drop down selection widget. Implements the onchange(value) event. Register a listener for its selection change by means of the function DropDown.onchange.connect.

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

empty()[source]

remove all children from the widget

get_item()[source]
Returns:

The selected item or None.

Return type:

DropDownItem

get_key()[source]
Returns:

The unique string identifier of the selected item or None.

Return type:

str

get_value()[source]
Returns:

The value of the selected item or None.

Return type:

str

classmethod new_from_list(items, **kwargs)[source]
onchange(value)[source]

Called when a new DropDownItem gets selected.

select_by_key(key)[source]

Selects an item by its unique string identifier.

Parameters:

key (str) – Unique string identifier of the DropDownItem that have to be selected.

select_by_value(value)[source]

Selects a DropDownItem by means of the contained text-

Parameters:

value (str) – Textual content of the DropDownItem that have to be selected.

set_value(value)[source]
class remi.gui.DropDownItem(text='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

item widget for the DropDown

get_text()[source]
Returns:

The text content of the Widget. You can set the text content with set_text(text).

Return type:

str

set_text(text)[source]

Sets the text label for the Widget.

Parameters:

text (str) – The string label of the Widget.

property value
class remi.gui.EventSource(*args, **kwargs)[source]

Bases: object

setup_event_methods()[source]
class remi.gui.FileDownloader(text, filename, path_separator='/', *args, **kwargs)[source]

Bases: Container, _MixinTextualWidget

FileDownloader widget. Allows to start a file download.

download()[source]
class remi.gui.FileFolderItem(path_and_filename, text, is_folder=False, *args, **kwargs)[source]

Bases: Container

FileFolderItem widget for the FileFolderNavigator

get_text()[source]
onclick(widget)[source]

Called when the Widget gets clicked by the user with the left mouse button.

onselection(widget)[source]
path_and_filename = None
set_selected(selected)[source]
set_text(t)[source]
class remi.gui.FileFolderNavigator(multiple_selection=False, selection_folder='.', allow_file_selection=True, allow_folder_selection=False, **kwargs)[source]

Bases: GridBox

FileFolderNavigator widget.

property allow_file_selection
property allow_folder_selection
chdir(directory)[source]
dir_go(widget)[source]
dir_go_back(widget)[source]
get_selected_filefolders()[source]
get_selection_list()[source]
property multiple_selection
on_folder_item_click(folderitem)[source]

This event occurs when a folder element is clicked. Returns the clicked element of type FileFolderItem.

on_folder_item_selected(folderitem)[source]

This event occurs when an element in the list is selected Returns the newly selected element of type FileFolderItem(or None if it was not selectable)

and the list of selected elements of type str.

populate_folder_items(directory)[source]
property selection_folder
class remi.gui.FileSelectionDialog(title='File dialog', message='Select files and folders', multiple_selection=True, selection_folder='.', allow_file_selection=True, allow_folder_selection=True, **kwargs)[source]

Bases: GenericDialog

file selection dialog, it opens a new webpage allows the OK/CANCEL functionality implementing the “confirm_value” and “cancel_dialog” events.

confirm_value(widget)[source]

event called pressing on OK button. propagates the string content of the input field

class remi.gui.FileUploader(savepath='./', multiple_selection_allowed=False, accepted_files='*.*', *args, **kwargs)[source]

Bases: Container

FileUploader widget:

allows to upload multiple files to a specified folder. implements the onsuccess and onfailed events.

property multiple_selection_allowed
ondata(filedata, filename)[source]
onfailed(filename)[source]
onsuccess(filename)[source]
property savepath
class remi.gui.GenericDialog(title='', message='', *args, **kwargs)[source]

Bases: Container

Generic Dialog widget. It can be customized to create personalized dialog windows. You can setup the content adding content widgets with the functions add_field or add_field_with_label. The user can confirm or dismiss the dialog with the common buttons Cancel/Ok. Each field added to the dialog can be retrieved by its key, in order to get back the edited value. Use the function

get_field(key) to retrieve the field.

The Ok button emits the ‘confirm_dialog’ event. Register the listener to it with set_on_confirm_dialog_listener. The Cancel button emits the ‘cancel_dialog’ event. Register the listener to it with set_on_cancel_dialog_listener.

add_field(key, field)[source]

Adds a field to the dialog with a unique identifier.

Note: You can access to the fields content calling the function GenericDialog.get_field(key).

Parameters:
  • key (str) – The unique identifier for the field.

  • field (Widget) – The widget to be added to the dialog, TextInput or any Widget for example.

add_field_with_label(key, label_description, field)[source]

Adds a field to the dialog together with a descriptive label and a unique identifier.

Note: You can access to the fields content calling the function GenericDialog.get_field(key).

Parameters:
  • key (str) – The unique identifier for the field.

  • label_description (str) – The string content of the description label.

  • field (Widget) – The instance of the field Widget. It can be for example a TextInput or maybe

  • widget. (a custom) –

cancel_dialog(emitter)[source]

Event generated by the Cancel button click.

confirm_dialog(emitter)[source]

Event generated by the OK button click.

get_field(key)[source]
Parameters:

key (str) – The unique string identifier of the required field.

Returns:

Widget field instance added previously with methods GenericDialog.add_field or GenericDialog.add_field_with_label.

hide()[source]
show(base_app_instance)[source]
class remi.gui.GenericObject(filename, **kwargs)[source]

Bases: Widget

GenericObject widget - allows to show embedded object like pdf,swf..

class remi.gui.GridBox(*args, **kwargs)[source]

Bases: Container

It contains widgets automatically aligning them to the grid. Does not permit children absolute positioning.

In order to add children to this container, use the append(child, key) function. The key have to be string and determines the children positioning in the layout.

Note: If you would absolute positioning, use the Container instead.

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param. The key have to correspond to a an element provided in the ‘define_grid’ method param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

property css_grid_gap
property css_grid_template_areas
property css_grid_template_columns
property css_grid_template_rows
define_grid(matrix)[source]

Populates the Table with a list of tuples of strings.

Parameters:

matrix (list) – list of iterables of strings (lists or something else). Items in the matrix have to correspond to a key for the children.

remove_child(child)[source]

Removes a child instance from the Tag’s children.

Parameters:

child (Tag) – The child to be removed.

set_column_gap(value)[source]

Sets the gap value between columns

Parameters:

value (int or str) – gap value (i.e. 10 or “10px”)

set_column_sizes(values)[source]

Sets the size value for each column

Parameters:

values (iterable of int or str) – values are treated as percentage.

set_from_asciiart(asciipattern, column_gap=0, row_gap=0)[source]

Defines the GridBox layout from a simple and intuitive ascii art table

Pipe “|” is the column separator. Rows are separated by

.

Identical rows are considered as unique bigger rows. Single table cells must contain the ‘key’ string value of the contained widgets. Column sizes are proportionally applied to the defined grid. Columns must be alligned between rows. The gap values eventually defined by set_column_gap and set_row_gap are overwritten.

es.

“”” | |label|button | | |text | | “””

Args:

asciipattern (str): The ascii defined grid column_gap (int): Percentage value of the total width to be used as gap between columns row_gap (int): Percentage value of the total height to be used as gap between rows

set_row_gap(value)[source]

Sets the gap value between rows

Parameters:

value (int or str) – gap value (i.e. 10 or “10px”)

set_row_sizes(values)[source]

Sets the size value for each row

Parameters:

values (iterable of int or str) – values are treated as percentage.

class remi.gui.HBox(*args, **kwargs)[source]

Bases: Container

The purpose of this widget is to automatically horizontally aligning

the widgets that are appended to it.

Does not permit children absolute positioning.

In order to add children to this container, use the append(child, key) function. The key have to be numeric and determines the children order in the layout.

Note: If you would absolute positioning, use the Container instead.

append(value, key='')[source]

It allows to add child widgets to this. The key allows to access the specific child in this way container.children[key]. The key have to be numeric and determines the children order in the layout.

Parameters:
  • value (Widget) – Child instance to be appended.

  • key (str) – Unique identifier for the child. If key.isdigit()==True ‘0’ ‘1’.. the value determines the order

  • layout (in the) –

class remi.gui.HEAD(title, *args, **kwargs)[source]

Bases: Tag

repr(changed_widgets=None)[source]

It is used to automatically represent the object to HTML format packs all the attributes, children and so on.

Parameters:

changed_widgets (dict) – A dictionary containing a collection of tags that have to be updated. The tag that have to be updated is the key, and the value is its textual repr.

set_icon_data(base64_data, mimetype='image/png', rel='icon')[source]

Allows to define an icon for the App

Parameters:
  • base64_data (str) – base64 encoded image data (ie. “data:image/x-icon;base64,AAABAAEAEBA….”)

  • mimetype (str) – mimetype of the image (“image/png” or “image/x-icon”…)

  • rel (str) – leave it unchanged (standard “icon”)

set_icon_file(filename, rel='icon')[source]

Allows to define an icon for the App

Parameters:
  • filename (str) – the resource file name (ie. “/res:myicon.png”)

  • rel (str) – leave it unchanged (standard “icon”)

set_internal_js(app_identifier, net_interface_ip, pending_messages_queue_length, websocket_timeout_timer_ms)[source]
set_title(title)[source]
class remi.gui.HTML(*args, **kwargs)[source]

Bases: Tag

repr(changed_widgets=None)[source]

It is used to automatically represent the object to HTML format packs all the attributes, children and so on.

Parameters:

changed_widgets (dict) – A dictionary containing a collection of tags that have to be updated. The tag that have to be updated is the key, and the value is its textual repr.

class remi.gui.Image(image='', *args, **kwargs)[source]

Bases: Widget

image widget.

property attr_src
set_image(image)[source]
Parameters:

image (str) – an url to an image or a base64 data string

class remi.gui.Input(input_type='', default_value='', *args, **kwargs)[source]

Bases: Widget

get_value()[source]

returns the new text value.

onchange(value)[source]
set_read_only(readonly)[source]
set_value(value)[source]
class remi.gui.InputDialog(title='Title', message='Message', initial_value='', *args, **kwargs)[source]

Bases: GenericDialog

Input Dialog widget. It can be used to query simple and short textual input to the user. The user can confirm or dismiss the dialog with the common buttons Cancel/Ok. The Ok button click or the ENTER key pression emits the ‘confirm_dialog’ event. Register the listener to it with set_on_confirm_dialog_listener. The Cancel button emits the ‘cancel_dialog’ event. Register the listener to it with set_on_cancel_dialog_listener.

confirm_value(widget)[source]

Event called pressing on OK button.

on_keydown_listener(widget, value, keycode)[source]

event called pressing on ENTER key.

propagates the string content of the input field

class remi.gui.Label(text='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

Non editable text label widget. Set its content by means of set_text function, and retrieve its content with the function get_text.

Bases: Container, _MixinTextualWidget

property attr_href
get_url()[source]
class remi.gui.ListItem(text='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

List item widget for the ListView.

ListItems are characterized by a textual content. They can be selected from the ListView. Do NOT manage directly its selection by registering set_on_click_listener, use instead the events of the ListView.

get_value()[source]
Returns:

The text content of the ListItem

Return type:

str

class remi.gui.ListView(selectable=True, *args, **kwargs)[source]

Bases: Container

List widget it can contain ListItems. Add items to it by using the standard append(item, key) function or generate a filled list from a string list by means of the function new_from_list. Use the list in conjunction of its onselection event. Register a listener with ListView.onselection.connect.

append(value, key='')[source]

Appends child items to the ListView. The items are accessible by list.children[key].

Parameters:
  • value (ListItem, or iterable of ListItems) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

empty()[source]

Removes all children from the list

get_item()[source]
Returns:

The selected item or None

Return type:

ListItem

get_key()[source]
Returns:

The key of the selected item or None if no item is selected.

Return type:

str

get_value()[source]
Returns:

The value of the selected item or None

Return type:

str

classmethod new_from_list(items, **kwargs)[source]

Populates the ListView with a string list.

Parameters:

items (list) – list of strings to fill the widget with.

onselection(widget)[source]

Called when a new item gets selected in the list.

select_by_key(key)[source]

Selects an item by its key.

Parameters:

key (str) – The unique string identifier of the item that have to be selected.

select_by_value(value)[source]

Selects an item by the text content of the child.

Parameters:

value (str) – Text content of the item that have to be selected.

set_value(value)[source]
class remi.gui.Menu(*args, **kwargs)[source]

Bases: Container

Menu widget can contain MenuItem.

class remi.gui.MenuBar(*args, **kwargs)[source]

Bases: Container

class remi.gui.MenuItem(text='', *args, **kwargs)[source]

Bases: Container, _MixinTextualWidget

MenuItem widget can contain other MenuItem.

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

onclick()[source]

Called when the Widget gets clicked by the user with the left mouse button.

class remi.gui.Progress(value=0, _max=100, *args, **kwargs)[source]

Bases: Widget

Progress bar widget.

property attr_max
property attr_value
set_max(_max)[source]
Parameters:

_max (int) – The maximum progress value.

set_value(value)[source]
Parameters:

value (int) – The actual progress value.

class remi.gui.SelectionInput(default_value='', input_type='text', *args, **kwargs)[source]

Bases: Input

selection input widget useful list selection field implements the oninput event. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist

property attr_datalist_identifier
property attr_input_type
property attr_value
get_datalist_identifier()[source]
get_value()[source]
Returns:

the actual value

Return type:

str

oninput(value)[source]
set_datalist_identifier(datalist)[source]
set_value(value)[source]
class remi.gui.SelectionInputWidget(iterable_of_str=None, default_value='', input_type='text', *args, **kwargs)[source]

Bases: Container

property attr_input_type
property attr_value
datalist = None
get_value()[source]
Returns:

the actual value

Return type:

str

oninput(emitter, value)[source]

This event occurs when user inputs a new value :returns: the string value :rtype: value (str)

selection_input = None
set_value(value)[source]

Sets the value of the widget :param value: the string value :type value: str

class remi.gui.Slider(default_value=0, min=0, max=65535, step=1, **kwargs)[source]

Bases: Input

property attr_max
property attr_min
property attr_step
property attr_value
oninput(value)[source]
class remi.gui.SpinBox(default_value=0, min_value=0, max_value=65535, step=1, allow_editing=True, **kwargs)[source]

Bases: Input

spin box widget useful as numeric input field implements the onchange event.

property attr_max
property attr_min
property attr_step
property attr_value
onchange(value)[source]
class remi.gui.Svg(*args, **kwargs)[source]

Bases: Container

svg widget - is a container for graphic widgets such as SvgCircle, SvgLine and so on.

property attr_preserveAspectRatio
property attr_viewBox
set_viewbox(x, y, w, h)[source]

Sets the origin and size of the viewbox, describing a virtual view area.

Parameters:
  • x (int) – x coordinate of the viewbox origin

  • y (int) – y coordinate of the viewbox origin

  • w (int) – width of the viewBox

  • h (int) – height of the viewBox

class remi.gui.SvgCircle(x=0, y=0, radius=50, *args, **kwargs)[source]

Bases: Widget, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

property attr_cx
property attr_cy
property attr_r
set_position(x, y)[source]

Sets the circle position.

Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

set_radius(radius)[source]

Sets the circle radius.

Parameters:

radius (int) – the circle radius

class remi.gui.SvgDefs(*args, **kwargs)[source]

Bases: Tag

class remi.gui.SvgEllipse(x=0, y=0, rx=50, ry=30, *args, **kwargs)[source]

Bases: Widget, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

property attr_cx
property attr_cy
property attr_rx
property attr_ry
set_position(x, y)[source]

Sets the ellipse position.

Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

set_radius(rx, ry)[source]

Sets the ellipse radius.

Parameters:
  • rx (int) – the ellipse radius

  • ry (int) – the ellipse radius

class remi.gui.SvgGradientLinear(x1, y1, x2, y2, *args, **kwargs)[source]

Bases: Tag

property attr_x1
property attr_x2
property attr_y1
property attr_y2
class remi.gui.SvgGradientRadial(cx='20%', cy='30%', r='30%', fx='50%', fy='50%', *args, **kwargs)[source]

Bases: Tag

property attr_cx
property attr_cy
property attr_fx
property attr_fy
property attr_r
class remi.gui.SvgGroup(*args, **kwargs)[source]

Bases: Container, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

svg group - a non visible container for svg widgets, this have to be appended into Svg elements.

class remi.gui.SvgImage(image_data='', x=0, y=0, w=100, h=100, *args, **kwargs)[source]

Bases: Widget, _MixinSvgPosition, _MixinSvgSize, _MixinTransformable

svg image - a raster image element for svg graphics, this have to be appended into Svg elements.

property attr_preserveAspectRatio
property image_data
class remi.gui.SvgLine(x1=0, y1=0, x2=50, y2=50, *args, **kwargs)[source]

Bases: Widget, _MixinSvgStroke, _MixinTransformable

property attr_x1
property attr_x2
property attr_y1
property attr_y2
set_coords(x1, y1, x2, y2)[source]
set_p1(x1, y1)[source]
set_p2(x2, y2)[source]
class remi.gui.SvgPath(path_value='', *args, **kwargs)[source]

Bases: Widget, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

add_arc(x, y, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag)[source]
add_position(x, y)[source]
property attr_d
class remi.gui.SvgPolygon(_maxlen=1000, *args, **kwargs)[source]

Bases: SvgPolyline, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

class remi.gui.SvgPolyline(_maxlen=1000, *args, **kwargs)[source]

Bases: Widget, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

add_coord(x, y)[source]
property maxlen
class remi.gui.SvgRectangle(x=0, y=0, w=100, h=100, *args, **kwargs)[source]

Bases: Widget, _MixinSvgPosition, _MixinSvgSize, _MixinSvgStroke, _MixinSvgFill, _MixinTransformable

property attr_round_corners_h
property attr_round_corners_y
class remi.gui.SvgStop(offset='0%', color='rgb(255,255,0)', opacity=1.0, *args, **kwargs)[source]

Bases: Tag

property attr_offset
property css_stop_color
property css_stop_opactity
class remi.gui.SvgSubcontainer(x=0, y=0, width=100, height=100, *args, **kwargs)[source]

Bases: Svg, _MixinSvgPosition, _MixinSvgSize

svg widget to nest within another Svg element- is a container for graphic widgets such as SvgCircle, SvgLine and so on.

class remi.gui.SvgText(x=10, y=10, text='svg text', *args, **kwargs)[source]

Bases: Widget, _MixinSvgPosition, _MixinSvgStroke, _MixinSvgFill, _MixinTextualWidget, _MixinTransformable

property attr_dominant_baseline
property attr_lengthAdjust
property attr_rotate
property attr_textLength
property attr_text_anchor
class remi.gui.TabBox(*args, **kwargs)[source]

Bases: Container

A multipage container. Add a tab by doing an append. ie. tabbox.append( widget, “Tab Name” ) The widget can be a container with other child widgets.

add_tab(widget, key, callback=None)[source]

This function is deprecated. Is here for compatibility reasons. The callback is ignored. Use append instead.

append(widget, key='')[source]

Adds a new tab. The widget is the content of the tab. The key is the tab title.

on_tab_selection(emitter, key)[source]
remove_child(widget)[source]

Removes a child instance from the Tag’s children.

Parameters:

child (Tag) – The child to be removed.

resize_tab_titles()[source]
select_by_index(index)[source]
select_by_key(key)[source]
select_by_name(key)[source]

This function is deprecated. Is here for compatibility reasons. Use select_by_key instead.

select_by_widget(widget)[source]
class remi.gui.Table(*args, **kwargs)[source]

Bases: Container

table widget - it will contains TableRow

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

append_from_list(content, fill_title=False)[source]

Appends rows created from the data contained in the provided list of tuples of strings. The first tuple of the list can be set as table title.

Parameters:
  • content (list) – list of tuples of strings. Each tuple is a row.

  • fill_title (bool) – if true, the first tuple in the list will be set as title.

classmethod new_from_list(content, fill_title=True, **kwargs)[source]

Populates the Table with a list of tuples of strings.

Parameters:
  • content (list) – list of tuples of strings. Each tuple is a row.

  • fill_title (bool) – if true, the first tuple in the list will be set as title

on_table_row_click(row, item)[source]
class remi.gui.TableEditableItem(text='', *args, **kwargs)[source]

Bases: Container, _MixinTextualWidget

item widget for the TableRow.

onchange(emitter, new_value)[source]
class remi.gui.TableItem(text='', *args, **kwargs)[source]

Bases: Container, _MixinTextualWidget

item widget for the TableRow.

class remi.gui.TableRow(*args, **kwargs)[source]

Bases: Container

row widget for the Table - it will contains TableItem

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

on_row_item_click(item)[source]

Event on item click.

Note: This is internally used by the Table widget in order to generate the

Table.on_table_row_click event. Use Table.on_table_row_click instead.

Parameters:
  • emitter (TableRow) – The emitter of the event.

  • item (TableItem) – The clicked TableItem.

class remi.gui.TableTitle(text='', *args, **kwargs)[source]

Bases: TableItem, _MixinTextualWidget

title widget for the table.

class remi.gui.TableWidget(n_rows=2, n_columns=2, use_title=True, editable=False, *args, **kwargs)[source]

Bases: Table

Basic table model widget. Each item is addressed by stringified integer key in the children dictionary.

property column_count
item_at(row, column)[source]

Returns the TableItem instance at row, column cordinates

Parameters:
  • row (int) – zero based index

  • column (int) – zero based index

item_coords(table_item)[source]

Returns table_item’s (row, column) cordinates. Returns None in case of item not found.

Parameters:

table_item (TableItem) – an item instance

on_item_changed(item, new_value, row, column)[source]

Event for the item change.

Parameters:
  • emitter (TableWidget) – The emitter of the event.

  • item (TableItem) – The TableItem instance.

  • new_value (str) – New text content.

  • row (int) – row index.

  • column (int) – column index.

property row_count
set_column_count(count)[source]

Sets the table column count.

Parameters:

count (int) – column of rows

set_row_count(count)[source]

Sets the table row count.

Parameters:

count (int) – number of rows

set_use_title(use_title)[source]

Returns the TableItem instance at row, column cordinates

Parameters:

use_title (bool) – enable title bar.

property use_title
class remi.gui.Tag(attributes=None, _type='', _class=None, **kwargs)[source]

Bases: object

Tag is the base class of the framework. It represents an element that can be added to the GUI, but it is not necessarily graphically representable.

add_child(key, value)[source]

Adds a child to the Tag

To retrieve the child call get_child or access to the Tag.children[key] dictionary.

Parameters:
  • key (str) – Unique child’s identifier, or iterable of keys

  • value (Tag, str) – can be a Tag, an iterable of Tag or a str. In case of iterable of Tag is a dict, each item’s key is set as ‘key’ param

add_class(cls)[source]
disable_refresh()[source]

Prevents the parent widgets to be notified about an update. This is required to improve performances in case of widgets updated

multiple times in a procedure.

disable_update()[source]

Prevents clients updates. Remi will not send websockets update messages. The widgets are however iternally updated. So if the user updates the

webpage, the update is shown.

empty()[source]

remove all children from the widget

enable_refresh()[source]
enable_update()[source]
get_child(key)[source]

Returns the child identified by ‘key’

Parameters:

key (str) – Unique identifier of the child.

get_parent()[source]

Returns the parent tag instance or None where not applicable

property identifier
innerHTML(local_changed_widgets)[source]
remove_child(child)[source]

Removes a child instance from the Tag’s children.

Parameters:

child (Tag) – The child to be removed.

remove_class(cls)[source]
repr(changed_widgets=None)[source]

It is used to automatically represent the object to HTML format packs all the attributes, children and so on.

Parameters:

changed_widgets (dict) – A dictionary containing a collection of tags that have to be updated. The tag that have to be updated is the key, and the value is its textual repr.

class remi.gui.TextInput(single_line=True, hint='', *args, **kwargs)[source]

Bases: Widget, _MixinTextualWidget

Editable multiline/single_line text area widget. You can set the content by means of the function set_text or retrieve its content with get_text.

property attr_maxlength
get_value()[source]
Returns:

The text content of the TextInput. You can set the text content with set_text(text).

Return type:

str

onchange(new_value)[source]

Called when the user changes the TextInput content. With single_line=True it fires in case of focus lost and Enter key pressed. With single_line=False it fires at each key released.

Parameters:

new_value (str) – the new string content of the TextInput.

onkeydown(new_value, keycode)[source]

Called when the user types a key into the TextInput.

Note: This event can’t be registered together with Widget.onchange.

Parameters:
  • new_value (str) – the new string content of the TextInput.

  • keycode (str) – the numeric char code

onkeyup(new_value, keycode)[source]

Called when user types and releases a key into the TextInput

Note: This event can’t be registered together with Widget.onchange.

Parameters:
  • new_value (str) – the new string content of the TextInput

  • keycode (str) – the numeric char code

set_value(text)[source]

Sets the text content.

Parameters:

text (str) – The string content that have to be appended as standard child identified by the key ‘text’

class remi.gui.TreeItem(text='', *args, **kwargs)[source]

Bases: Container, _MixinTextualWidget

TreeItem widget can contain other TreeItem.

append(value, key='')[source]

Adds a child widget, generating and returning a key if not provided

In order to access to the specific child in this way container.children[key].

Parameters:
  • value (Widget, or iterable of Widgets) – The child to be appended. In case of a dictionary, each item’s key is used as ‘key’ param for the single append.

  • key (str) – The unique string identifier for the child. Ignored in case of iterable ‘value’ param.

Returns:

a key used to refer to the child for all future interaction, or a list of keys in case

of an iterable ‘value’ param

Return type:

str

onclick()[source]

Called when the Widget gets clicked by the user with the left mouse button.

class remi.gui.TreeView(*args, **kwargs)[source]

Bases: Container

TreeView widget can contain TreeItem.

class remi.gui.VBox(*args, **kwargs)[source]

Bases: HBox

The purpose of this widget is to automatically vertically aligning

the widgets that are appended to it.

Does not permit children absolute positioning.

In order to add children to this container, use the append(child, key) function. The key have to be numeric and determines the children order in the layout.

Note: If you would absolute positioning, use the Container instead.

class remi.gui.VideoPlayer(video='', poster=None, autoplay=False, loop=False, *args, **kwargs)[source]

Bases: Widget

property attr_autoplay
property attr_loop
property attr_poster
property attr_src
property attr_type
onended()[source]

Called when the media has been played and reached the end.

set_autoplay(autoplay)[source]
set_loop(loop)[source]

Sets the VideoPlayer to restart video when finished.

Note: If set as True the event onended will not fire.

class remi.gui.Widget(style=None, *args, **kwargs)[source]

Bases: Tag, EventSource

Base class for graphical gui widgets. A widget has a graphical css style and receives events from the webpage

EVENT_ONBLUR = 'onblur'
EVENT_ONCHANGE = 'onchange'
EVENT_ONCLICK = 'onclick'
EVENT_ONCONTEXTMENU = 'oncontextmenu'
EVENT_ONDBLCLICK = 'ondblclick'
EVENT_ONFOCUS = 'onfocus'
EVENT_ONINPUT = 'oninput'
EVENT_ONKEYDOWN = 'onkeydown'
EVENT_ONKEYPRESS = 'onkeypress'
EVENT_ONKEYUP = 'onkeyup'
EVENT_ONMOUSEDOWN = 'onmousedown'
EVENT_ONMOUSELEAVE = 'onmouseleave'
EVENT_ONMOUSEMOVE = 'onmousemove'
EVENT_ONMOUSEOUT = 'onmouseout'
EVENT_ONMOUSEOVER = 'onmouseover'
EVENT_ONMOUSEUP = 'onmouseup'
EVENT_ONTOUCHCANCEL = 'ontouchcancel'
EVENT_ONTOUCHEND = 'ontouchend'
EVENT_ONTOUCHENTER = 'ontouchenter'
EVENT_ONTOUCHLEAVE = 'ontouchleave'
EVENT_ONTOUCHMOVE = 'ontouchmove'
EVENT_ONTOUCHSTART = 'ontouchstart'
EVENT_ONUPDATE = 'onupdate'
property attr_class
property attr_editor_newclass
property attr_title
property css_align_content
property css_align_items
property css_align_self
property css_background_color
property css_background_image
property css_background_position
property css_background_repeat
property css_border_color
property css_border_radius
property css_border_style
property css_border_width
property css_bottom
property css_color
property css_display
property css_flex
property css_flex_direction
property css_flex_flow
property css_flex_wrap
property css_float
property css_font_family
property css_font_size
property css_font_style
property css_font_weight
property css_height
property css_justify_content
property css_left
property css_letter_spacing
property css_line_height
property css_margin
property css_opacity
property css_order
property css_overflow
property css_position
property css_right
property css_top
property css_visibility
property css_white_space
property css_width
get_enabled()[source]

Returns a bool.

onblur()[source]

Called when the Widget loses focus

onclick()[source]

Called when the Widget gets clicked by the user with the left mouse button.

oncontextmenu()[source]

Called when the Widget gets clicked by the user with the right mouse button.

ondblclick()[source]

Called when the Widget gets double clicked by the user with the left mouse button.

onfocus()[source]

Called when the Widget gets focus.

onkeydown(key, keycode, ctrl, shift, alt)[source]

Called when user types and releases a key. The widget should be able to receive the focus in order to emit the event. Assign a ‘tabindex’ attribute to make it focusable.

Parameters:
  • key (str) – the character value

  • keycode (str) – the numeric char code

onkeyup(key, keycode, ctrl, shift, alt)[source]

Called when user types and releases a key. The widget should be able to receive the focus in order to emit the event. Assign a ‘tabindex’ attribute to make it focusable.

Parameters:
  • key (str) – the character value

  • keycode (str) – the numeric char code

onmousedown(x, y)[source]

Called when the user presses left or right mouse button over a Widget.

Parameters:
  • x (float) – position of the mouse inside the widget

  • y (float) – position of the mouse inside the widget

onmouseleave()[source]

Called when the mouse cursor moves outside a Widget.

Note: This event is often used together with the Widget.onmouseenter event, which occurs when the mouse pointer

is moved onto a Widget.

Note: The Widget.onmouseleave event is similar to the Widget.onmouseout event. The only difference is that the

onmouseleave event does not bubble (does not propagate up the Widgets tree).

onmousemove(x, y)[source]

Called when the mouse cursor moves inside the Widget.

Parameters:
  • x (float) – position of the mouse inside the widget

  • y (float) – position of the mouse inside the widget

onmouseout()[source]

Called when the mouse cursor moves outside a Widget.

Note: This event is often used together with the Widget.onmouseover event, which occurs when the pointer is

moved onto a Widget, or onto one of its children.

onmouseover()[source]

Called when the mouse cursor moves onto a Widget.

Note: This event is often used together with the Widget.onmouseout event.

onmouseup(x, y)[source]

Called when the user releases left or right mouse button over a Widget.

Parameters:
  • x (float) – position of the mouse inside the widget

  • y (float) – position of the mouse inside the widget

onquery_client_result(**kwargs)[source]

WARNING: this is a new feature, subject to changes. This event allows to get back the values fetched by ‘query’ method. :returns: a dictionary containing name:value of all the requested parameters :rtype: values_dictionary (dict)

ontouchcancel()[source]

Called when a touch point has been disrupted in an implementation-specific manner (for example, too many touch points are created).

ontouchend(x, y)[source]

Called when a finger is released from the widget.

Parameters:
  • x (float) – position of the finger inside the widget

  • y (float) – position of the finger inside the widget

ontouchenter(x, y)[source]

Called when a finger touches from outside to inside the widget.

Parameters:
  • x (float) – position of the finger inside the widget

  • y (float) – position of the finger inside the widget

ontouchleave()[source]

Called when a finger touches from inside to outside the widget.

ontouchmove(x, y)[source]

Called continuously while a finger is dragged across the screen, over a Widget.

Parameters:
  • x (float) – position of the finger inside the widget

  • y (float) – position of the finger inside the widget

ontouchstart(x, y)[source]

Called when a finger touches the widget.

Parameters:
  • x (float) – position of the finger inside the widget

  • y (float) – position of the finger inside the widget

query_client(app_instance, attribute_list, style_property_list)[source]

WARNING: this is a new feature, subject to changes. This method allows to query client rendering attributes and style properties of a widget. The user, in order to get back the values must register a listener for the event ‘onquery_client_result’. :param app_instance: the app instance :type app_instance: App :param attribute_list: list of attributes names :type attribute_list: list :param style_property_list: list of style property names :type style_property_list: list

redraw()[source]

Forces a graphic update of the widget

repr(changed_widgets=None)[source]

Represents the widget as HTML format, packs all the attributes, children and so on.

Parameters:

changed_widgets (dict) – A dictionary containing a collection of widgets that have to be updated. The Widget that have to be updated is the key, and the value is its textual repr.

set_enabled(enabled)[source]

Sets the enabled status. If a widget is disabled the user iteraction is not allowed

Parameters:

enabled (bool) – the enabling flag

set_size(width, height)[source]

Set the widget size.

Parameters:
  • width (int or str) – An optional width for the widget (es. width=10 or width=’10px’ or width=’10%’).

  • height (int or str) – An optional height for the widget (es. height=10 or height=’10px’ or height=’10%’).

set_style(style)[source]

Allows to set style properties for the widget. :param style: The style property dictionary or json string. :type style: str or dict

property variable_name
remi.gui.decorate_event(method)[source]

setup a method as an event

remi.gui.decorate_event_js(js_code)[source]

setup a method as an event, adding also javascript code to generate

Parameters:

js_code (str) – javascript code to generate the event client-side. js_code is added to the widget html as widget.attributes[‘onclick’] = js_code%{‘emitter_identifier’:widget.identifier, ‘event_name’:’onclick’}

remi.gui.decorate_set_on_listener(prototype)[source]

Private decorator for use in the editor. Allows the Editor to create listener methods.

Parameters:

params (str) – The list of parameters for the listener method (es. “(self, new_value)”)

remi.gui.editor_attribute_decorator(group, description, _type, additional_data)[source]
remi.gui.from_pix(x)[source]
remi.gui.jsonize(d)[source]
remi.gui.load_resource(filename)[source]

Convenient function. Given a local path and filename (not in standard remi resource format), loads the content and returns a base64 encoded data. This method allows to bypass the remi resource file management, accessing directly local disk files.

Parameters:

filename (str) – path and filename of a local file (ie. “/home/mydirectory/image.png”)

Returns:

the encoded base64 data together with mimetype packed to be displayed immediately.

Return type:

str

remi.gui.to_pix(x)[source]
remi.gui.to_uri(uri_data)[source]

Convenient function to encase the resource filename or data in url(‘’) keyword

Parameters:

uri_data (str) – filename or base64 data of the resource file

Returns:

the input string encased in url(‘’) ie. url(‘/res:image.png’)

Return type:

str

remi.server module

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class remi.server.App(request, client_address, server, **app_args)[source]

Bases: BaseHTTPRequestHandler, object

This class will handles any incoming request from the browser The main application class can subclass this In the do_POST and do_GET methods it is expected to receive requests such as:

  • function calls with parameters

  • file requests

all_paths()[source]
close()[source]

Command to initiate an App to close

do_AUTHHEAD()[source]
do_GET()[source]
do_HEAD()[source]
do_POST()[source]
do_gui_update()[source]

This method gets called also by Timer, a new thread, and so needs to lock the update

execute_javascript(code)[source]
idle()[source]

Idle function called every UPDATE_INTERVAL before the gui update. Useful to schedule tasks.

main(*_)[source]

Subclasses of App class must declare a main function that will be the entry point of the application. Inside the main function you have to declare the GUI structure and return the root widget.

notification_message(title, content, icon='')[source]

This function sends “javascript” message to the client, that executes its content. In this particular code, a notification message is shown

on_close()[source]

Called by the server when the App have to be terminated

onerror(message, source, lineno, colno, error)[source]

WebPage Event that occurs on webpage errors

onload(emitter)[source]

WebPage Event that occurs on webpage loaded

ononline(emitter)[source]

WebPage Event that occurs on webpage goes online after a disconnection

onpagehide(emitter)[source]

WebPage Event that occurs on webpage when the user navigates away

onpageshow(emitter, width, height)[source]

WebPage Event that occurs on webpage gets shown

onresize(emitter, width, height)[source]

WebPage Event that occurs on webpage gets resized

re_attr_call = re.compile('^/*(\\w+)\\/(\\w+)\\?{0,1}(\\w*\\={1}([^&])+\\&{0,1})*$')
re_static_file = re.compile("^([\\/]*[\\w\\d]+:[-_. $@?#£'%=()\\/\\[\\]!+°§^,\\w\\d]+)")
set_root_widget(widget)[source]
websocket_handshake_done(ws_instance_to_update)[source]
class remi.server.Server(gui_class, title='', start=True, address='127.0.0.1', port=0, username=None, password=None, multiple_instance=False, enable_file_cache=True, update_interval=0.1, start_browser=True, websocket_timeout_timer_ms=1000, pending_messages_queue_length=1000, certfile=None, keyfile=None, ssl_version=None, userdata=())[source]

Bases: object

property address
serve_forever()[source]
start()[source]
stop()[source]
property title
class remi.server.StandaloneServer(gui_class, title='', width=800, height=600, resizable=True, fullscreen=False, start=True, userdata=())[source]

Bases: Server

serve_forever()[source]
class remi.server.ThreadedHTTPServer(server_address, RequestHandlerClass, auth, multiple_instance, enable_file_cache, update_interval, websocket_timeout_timer_ms, pending_messages_queue_length, title, server_starter_instance, certfile, keyfile, ssl_version, *userdata)[source]

Bases: ThreadingMixIn, HTTPServer

daemon_threads = False
class remi.server.WebSocketsHandler(headers, request, client_address, server, *args, **kwargs)[source]

Bases: StreamRequestHandler

static bytetonum(b)[source]
close(terminate_server=True)[source]
handle()[source]
handshake()[source]
magic = b'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
on_message(message)[source]
read_next_message()[source]
send_message(message)[source]
setup()[source]
remi.server.encode_text(data)[source]
remi.server.from_websocket(data)[source]
remi.server.get_method_by_id(_id)[source]
remi.server.get_method_by_name(root_node, name)[source]
remi.server.gzip_encode(content)[source]
remi.server.parse_parametrs(p)[source]

Parses the parameters given from POST or websocket reqs expecting the parameters as: “11|par1=’asd’|6|par2=1” returns a dict like {par1:’asd’,par2:1}

cookie_to_cook = http_header[‘cookie’]

remi.server.start(main_gui_class, **kwargs)[source]

This method starts the webserver with a specific App subclass.

remi.server.to_websocket(data)[source]

Module contents