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 / gui.py 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'):
        self.style['stroke'] = color
        self.style['stroke-width'] = str(width)


class SvgPolyline(Widget):
    @decorate_constructor_parameter_types([int])
    def __init__(self, _maxlen=None, **kwargs):
        super(SvgPolyline, self).__init__(**kwargs)
        self.set_stroke()
        self.style['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 / gui.py 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)
        l.sort(key=cmp_to_key(_sort_files))

        # 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
        self.remove_child(self.itemContainer)
        # creation of a new instance of a itemContainer
        self.itemContainer = Widget()
        self.itemContainer.set_layout_orientation(Widget.LAYOUT_VERTICAL)
        self.itemContainer.style['overflow-y'] = 'scroll'
        self.itemContainer.style['overflow-x'] = 'hidden'
        self.itemContainer.style['height'] = '300px'
        self.itemContainer.style['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):
                continue
            fi = FileFolderItem(i, is_folder)
            fi.style['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
            self.folderItems.append(fi)
github hallee / espresso-arm / remi / remi / gui.py 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 / gui.py 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).

        Args:
            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()
        container.style['display'] = 'block'
        container.style['overflow'] = 'auto'
        container.style['padding'] = '3px'
        container.set_layout_orientation(Widget.LAYOUT_HORIZONTAL)
        container.append(self.inputs[key], key=key)
        self.container.append(container, key=key)
github hallee / espresso-arm / remi / remi / gui.py 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.

        Args:
            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'

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

    @decorate_constructor_parameter_types([str])
    def __init__(self, filename, **kwargs):
        """
        Args:
            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.set_layout_orientation(Widget.LAYOUT_VERTICAL)

        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')
        self.controlsContainer.style['display'] = 'flex'
        self.controlsContainer.set_layout_orientation(Widget.LAYOUT_VERTICAL)
        self.controlBack = Button('Up')
github hallee / espresso-arm / remi / remi / gui.py View on Github external
"""Sets the text content.

        Args:
            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):
        """
        Returns:
            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):
        """
        Args:
github hallee / espresso-arm / remi / remi / gui.py 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.
    """

    @decorate_constructor_parameter_types([])
    def __init__(self, **kwargs):
        super(VBox, self).__init__(**kwargs)
        self.style['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.
    """
    @decorate_constructor_parameter_types([str])
    def __init__(self, text='', **kwargs):
        """
        Args:
            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)
        self.set_text(text)

    def set_text(self, text):