How to use the remi.gui._MixinTextualWidget 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 KenT2 / pipresents-gapless / remi / gui.py View on Github external
return self.eventManager.propagate(self.EVENT_ONCHANGE, (value,))

    @decorate_set_on_listener("onchange", "(self,emitter,new_value)")
    def set_on_change_listener(self, callback, *userdata):
        """Registers the listener for the DropDown.onchange event.

        Note: The prototype of the listener have to be like my_dropdown_onchange(self, widget, value). Where value is
        the textual content of the selected item.

        Args:
            callback (function): Callback function pointer.
        """
        self.eventManager.register_listener(self.EVENT_ONCHANGE, callback, *userdata)


class DropDownItem(Widget, _MixinTextualWidget):
    """item widget for the DropDown"""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text, **kwargs):
        """
        Args:
            kwargs: See Widget.__init__()
        """
        super(DropDownItem, self).__init__(**kwargs)
        self.type = 'option'
        self.attributes[self.EVENT_ONCLICK] = ''
        self.set_text(text)

    def set_value(self, text):
        return self.set_text(text)
github dddomodossola / remi / remi / gui.py View on Github external
Note: This is internally used by the Table widget in order to generate the
            Table.on_table_row_click event.
            Use Table.set_on_table_row_click_listener instead.
        Note: The prototype of the listener have to be like
            on_row_item_click(self, row, item).

        Args:
            callback (function): Callback function pointer.
            row (TableRow): The emitter of the event.
            item (TableItem): The clicked TableItem.
        """
        self.eventManager.register_listener(self.EVENT_ON_ROW_ITEM_CLICK, callback, *userdata)


class TableEditableItem(Widget, _MixinTextualWidget):
    """item widget for the TableRow."""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text='', **kwargs):
        """
        Args:
            text (str):
            kwargs: See Widget.__init__()
        """
        super(TableEditableItem, self).__init__(**kwargs)
        self.type = 'td'
        self.editInput = TextInput()
        self.append(self.editInput)
        self.editInput.set_on_change_listener(self.onchange)
        self.get_text = self.editInput.get_text
        self.set_text = self.editInput.set_text
github dddomodossola / remi / remi / gui.py View on Github external
class TableItem(Widget, _MixinTextualWidget):
    """item widget for the TableRow."""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text='', *args, **kwargs):
        """
        Args:
            text (str):
            kwargs: See Widget.__init__()
        """
        super(TableItem, self).__init__(*args, **kwargs)
        self.type = 'td'
        self.set_text(text)


class TableTitle(TableItem, _MixinTextualWidget):
    """title widget for the table."""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text='', *args, **kwargs):
        """
        Args:
            text (str):
            kwargs: See Widget.__init__()
        """
        super(TableTitle, self).__init__(text, *args, **kwargs)
        self.type = 'th'


class Input(Tag):

    @decorate_constructor_parameter_types([str, str])
github dddomodossola / remi / remi / gui.py View on Github external
def add_coord(self, x, y):
        if len(self.coordsX) == self.maxlen:
            spacepos = self.attributes['points'].find(' ')
            if spacepos > 0:
                self.attributes['points'] = self.attributes['points'][spacepos + 1:]
        self.coordsX.append(x)
        self.coordsY.append(y)
        self.attributes['points'] += "%s,%s " % (x, y)

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


class SvgText(SvgShape, _MixinTextualWidget):

    @decorate_constructor_parameter_types([int, int, str])
    def __init__(self, x, y, text, **kwargs):
        super(SvgText, self).__init__(x, y, **kwargs)
        self.type = 'text'
        self.set_fill()
        self.set_stroke(0)
        self.set_text(text)
github KenT2 / pipresents-beep / remi / gui.py View on Github external
self.type = 'a'
        self.attributes['download'] = os.path.basename(filename)
        self.attributes['href'] = "/%s/download" % self.identifier
        self.set_text(text)
        self._filename = filename
        self._path_separator = path_separator

    def download(self):
        with open(self._filename, 'r+b') as f:
            content = f.read()
        headers = {'Content-type': 'application/octet-stream',
                   'Content-Disposition': 'attachment; filename=%s' % os.path.basename(self._filename)}
        return [content, headers]


class Link(Widget, _MixinTextualWidget):
    @decorate_constructor_parameter_types([str, str, bool])
    def __init__(self, url, text, open_new_window=True, **kwargs):
        super(Link, self).__init__(**kwargs)
        self.type = 'a'
        self.attributes['href'] = url
        if open_new_window:
            self.attributes['target'] = "_blank"
        self.set_text(text)

    def get_url(self):
        return self.attributes['href']


class VideoPlayer(Widget):
    # some constants for the events
    EVENT_ONENDED = 'onended'
github dddomodossola / remi / remi / gui.py View on Github external
return (filedata, filename)

    @decorate_explicit_alias_for_listener_registration
    def set_on_success_listener(self, callback, *userdata):
        self.onsuccess.connect(callback, *userdata)

    @decorate_explicit_alias_for_listener_registration
    def set_on_failed_listener(self, callback, *userdata):
        self.onfailed.connect(callback, *userdata)

    @decorate_explicit_alias_for_listener_registration
    def set_on_data_listener(self, callback, *userdata):
        self.ondata.connect(callback, *userdata)


class FileDownloader(Widget, _MixinTextualWidget):
    """FileDownloader widget. Allows to start a file download."""

    @decorate_constructor_parameter_types([str, str, str])
    def __init__(self, text, filename, path_separator='/', *args, **kwargs):
        super(FileDownloader, self).__init__(*args, **kwargs)
        self.type = 'a'
        self.attributes['download'] = os.path.basename(filename)
        self.attributes['href'] = "/%s/download" % self.identifier
        self.set_text(text)
        self._filename = filename
        self._path_separator = path_separator

    def download(self):
        with open(self._filename, 'r+b') as f:
            content = f.read()
        headers = {'Content-type': 'application/octet-stream',
github dddomodossola / remi / remi / gui.py View on Github external
self.onchange.connect(callback, *userdata)

    @decorate_explicit_alias_for_listener_registration
    def set_on_key_up_listener(self, callback, *userdata):
        self.onkeyup.connect(callback, *userdata)

    @decorate_explicit_alias_for_listener_registration
    def set_on_key_down_listener(self, callback, *userdata):
        self.onkeydown.connect(callback, *userdata)

    @decorate_explicit_alias_for_listener_registration
    def set_on_enter_listener(self, callback, *userdata):
        self.onenter.connect(callback, *userdata)


class Label(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.
    """

    @decorate_constructor_parameter_types([str])
    def __init__(self, text, *args, **kwargs):
        """
        Args:
            text (str): The string content that have to be displayed in the Label.
            kwargs: See Widget.__init__()
        """
        super(Label, self).__init__(*args, **kwargs)
        self.type = 'p'
        self.set_text(text)
github KenT2 / pipresents-beep / remi / gui.py View on Github external
class Menu(Widget):
    """Menu widget can contain MenuItem."""

    @decorate_constructor_parameter_types([])
    def __init__(self, **kwargs):
        """
        Args:
            kwargs: See Widget.__init__()
        """
        super(Menu, self).__init__(**kwargs)
        self.type = 'ul'
        self.set_layout_orientation(Widget.LAYOUT_HORIZONTAL)


class MenuItem(Widget, _MixinTextualWidget):
    """MenuItem widget can contain other MenuItem."""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text, **kwargs):
        """
        Args:
            text (str):
            kwargs: See Widget.__init__()
        """
        super(MenuItem, self).__init__(**kwargs)
        self.sub_container = None
        self.type = 'li'
        self.attributes[self.EVENT_ONCLICK] = ''
        self.set_text(text)

    def append(self, value, key=''):
github dddomodossola / remi / remi / gui.py View on Github external
def ondata(self, filedata, filename):
        with open(os.path.join(self._savepath, filename), 'wb') as f:
            f.write(filedata)
        return self.eventManager.propagate(self.EVENT_ON_DATA, (filedata, filename))

    @decorate_set_on_listener("ondata", "(self,emitter,filedata, filename)")
    def set_on_data_listener(self, callback, *userdata):
        """Register the listener for the ondata event.

        Note: the listener prototype have to be in the form on_fileupload_data(self, widget, filedata, filename),
            where filedata is the bytearray chunk.
        """
        self.eventManager.register_listener(self.EVENT_ON_DATA, callback, *userdata)


class FileDownloader(Widget, _MixinTextualWidget):
    """FileDownloader widget. Allows to start a file download."""

    @decorate_constructor_parameter_types([str, str, str])
    def __init__(self, text, filename, path_separator='/', **kwargs):
        super(FileDownloader, self).__init__(**kwargs)
        self.type = 'a'
        self.attributes['download'] = os.path.basename(filename)
        self.attributes['href'] = "/%s/download" % self.identifier
        self.set_text(text)
        self._filename = filename
        self._path_separator = path_separator

    def download(self):
        with open(self._filename, 'r+b') as f:
            content = f.read()
        headers = {'Content-type': 'application/octet-stream',
github KenT2 / pipresents-gapless / remi / gui.py View on Github external
class Menu(Widget):
    """Menu widget can contain MenuItem."""

    @decorate_constructor_parameter_types([])
    def __init__(self, **kwargs):
        """
        Args:
            kwargs: See Widget.__init__()
        """
        super(Menu, self).__init__(**kwargs)
        self.type = 'ul'
        self.set_layout_orientation(Widget.LAYOUT_HORIZONTAL)


class MenuItem(Widget, _MixinTextualWidget):
    """MenuItem widget can contain other MenuItem."""

    @decorate_constructor_parameter_types([str])
    def __init__(self, text, **kwargs):
        """
        Args:
            text (str):
            kwargs: See Widget.__init__()
        """
        super(MenuItem, self).__init__(**kwargs)
        self.sub_container = None
        self.type = 'li'
        self.attributes[self.EVENT_ONCLICK] = ''
        self.set_text(text)

    def append(self, value, key=''):