How to use the remi.remi.gui.Widget function in remi

To help you get started, we’ve selected a few remi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hallee / espresso-arm / remi / remi / View on Github external
self.set_p2(x2, y2)

    def set_p1(self, x1, y1):
        self.attributes['x1'] = x1
        self.attributes['y1'] = y1

    def set_p2(self, x2, y2):
        self.attributes['x2'] = x2
        self.attributes['y2'] = y2

    def set_stroke(self, width=1, color='black'):['stroke'] = color['stroke-width'] = str(width)

class SvgPolyline(Widget):
    def __init__(self, _maxlen=None, **kwargs):
        super(SvgPolyline, self).__init__(**kwargs)
        self.set_stroke()['fill'] = 'none'
        self.type = 'polyline'
        self.coordsX = collections.deque(maxlen=_maxlen)
        self.coordsY = collections.deque(maxlen=_maxlen)
        self.maxlen = _maxlen  # no limit
        self.attributes['points'] = ''
        self.attributes['vector-effect'] = 'non-scaling-stroke'

    def add_coord(self, x, y):
        if len(self.coordsX) == self.maxlen:
            spacepos = self.attributes['points'].find(' ')
            if spacepos > 0:
github hallee / espresso-arm / remi / remi / View on Github external
return a.lower() > b.lower()
                except (IndexError, ValueError):
                    return a > b

        log.debug("FileFolderNavigator - populate_folder_items")

        l = os.listdir(directory)

        # used to restore a valid path after a wrong edit in the path editor
        self.lastValidPath = directory
        # we remove the container avoiding graphic update adding items
        # this speeds up the navigation
        # creation of a new instance of a itemContainer
        self.itemContainer = Widget()
        self.itemContainer.set_layout_orientation(Widget.LAYOUT_VERTICAL)['overflow-y'] = 'scroll'['overflow-x'] = 'hidden'['height'] = '300px'['display'] = 'block'

        for i in l:
            full_path = os.path.join(directory, i)
            is_folder = not os.path.isfile(full_path)
            if (not is_folder) and (not self.allow_file_selection):
            fi = FileFolderItem(i, is_folder)
  ['display'] = 'block'
            fi.set_on_click_listener(self, 'on_folder_item_click')  # navigation purpose
            fi.set_on_selection_listener(self, 'on_folder_item_selected')  # selection purpose
github hallee / espresso-arm / remi / remi / View on Github external
def get_url(self):
        return self.attributes['href']

class VideoPlayer(Widget):
    @decorate_constructor_parameter_types([str, str])
    def __init__(self, video, poster=None, **kwargs):
        super(VideoPlayer, self).__init__(**kwargs)
        self.type = 'video'
        self.attributes['src'] = video
        self.attributes['preload'] = 'auto'
        self.attributes['controls'] = None
        self.attributes['poster'] = poster

class Svg(Widget):
    @decorate_constructor_parameter_types([int, int])
    def __init__(self, width, height, **kwargs):
        super(Svg, self).__init__(**kwargs)
        self.set_size(width, height)
        self.attributes['width'] = width
        self.attributes['height'] = height
        self.type = 'svg'

    def set_viewbox(self, x, y, w, h):
        self.attributes['viewBox'] = "%s %s %s %s" % (x, y, w, h)
        self.attributes['preserveAspectRatio'] = 'none'

class SvgCircle(Widget):
    @decorate_constructor_parameter_types([int, int, int])
    def __init__(self, x, y, radix, **kwargs):
github hallee / espresso-arm / remi / remi / View on Github external
def add_field(self, key, field):
        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).

            key (str): The unique identifier for the field.
            field (Widget): The widget to be added to the dialog, TextInput or any Widget for example.
        self.inputs[key] = field
        container = Widget()['display'] = 'block'['overflow'] = 'auto'['padding'] = '3px'
        container.append(self.inputs[key], key=key)
        self.container.append(container, key=key)
github hallee / espresso-arm / remi / remi / View on Github external
    @decorate_set_on_listener("confirm_value", "(self,value)")
    def set_on_confirm_value_listener(self, listener, funcname):
        """Registers the listener for the InputDialog.confirm_value event.

        Note: The prototype of the listener have to be like my_on_confirm_dialog(self, confirmed_value), where
            confirmed_value is the text content of the input field.

            listener (App, Widget): Instance of the listener. It can be the App or a Widget.
            funcname (str): Literal name of the listener function, member of the listener instance
        self.eventManager.register_listener(self.EVENT_ONCONFIRMVALUE, listener, funcname)

class ListView(Widget):
    """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.set_on_selection_listener.

    EVENT_ONSELECTION = 'onselection'

    def __init__(self, **kwargs):
            kwargs: See Widget.__init__()
        super(ListView, self).__init__(**kwargs)
        self.type = 'ul'
        self.selected_item = None
github hallee / espresso-arm / remi / remi / View on Github external
GenericObject widget - allows to show embedded object like pdf,swf..

    def __init__(self, filename, **kwargs):
            filename (str): URL
            kwargs: See Widget.__init__()
        super(GenericObject, self).__init__(**kwargs)
        self.type = 'object'
        self.attributes['data'] = filename

class FileFolderNavigator(Widget):
    """FileFolderNavigator widget."""

    @decorate_constructor_parameter_types([bool, str, bool, bool])
    def __init__(self, multiple_selection, selection_folder, allow_file_selection, allow_folder_selection, **kwargs):
        super(FileFolderNavigator, self).__init__(**kwargs)

        self.multiple_selection = multiple_selection
        self.allow_file_selection = allow_file_selection
        self.allow_folder_selection = allow_folder_selection
        self.selectionlist = []
        self.controlsContainer = Widget()
        self.controlsContainer.set_size('100%', '30px')['display'] = 'flex'
        self.controlBack = Button('Up')
github hallee / espresso-arm / remi / remi / View on Github external
"""Sets the text content.

            text (str): The string content that have to be appended as standard child identified by the key 'text'
        self.add_child('text', text)

    def get_text(self):
            str: The text content of the label. You can set the text content with set_text(text).
        return self.get_child('text')

class GenericDialog(Widget):
    """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.

    EVENT_ONCONFIRM = 'confirm_dialog'
    EVENT_ONCANCEL = 'cancel_dialog'

    @decorate_constructor_parameter_types([str, str])
    def __init__(self, title='', message='', **kwargs):
github hallee / espresso-arm / remi / remi / View on Github external
"""It contains widget automatically aligning them vertically.
    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 Widget container instead.

    def __init__(self, **kwargs):
        super(VBox, self).__init__(**kwargs)['flex-direction'] = 'column'

class Button(Widget):
    """The Button widget. Have to be used in conjunction with its event onclick.
    Use Widget.set_on_click_listener in order to register the listener.
    def __init__(self, text='', **kwargs):
            text (str): The text that will be displayed on the button.
            kwargs: See Widget.__init__()
        super(Button, self).__init__(**kwargs)
        self.type = 'button'
        self.attributes[self.EVENT_ONCLICK] = "sendCallback('%s','%s');" % (id(self), self.EVENT_ONCLICK)

    def set_text(self, text):