How to use the flexx.flx.reaction function in flexx

To help you get started, we’ve selected a few flexx 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 flexxui / flexx / flexxamples / howtos / redirect.py View on Github external
    @flx.reaction('but2.pointer_click')
    def on_opennew(self, *events):
        global window
        window.open('http://python.org', '_blank')
github leo-editor / leo-editor / leo / plugins / leoflexx_js.py View on Github external
    @flx.reaction('size')
    def __on_size(self, *events):
        self.ace.resize()
#@+node:ekr.20181110170304.1: ** class LeoMainWindow
github flexxui / flexx / flexxamples / howtos / deep_event_connections.py View on Github external
    @flx.reaction('!children**.value')
    def on_slider_change(self, *events):
        for ev in events:
            self.label.set_text('Slider %s changed to %f' %
                                (ev.source.id, ev.new_value))
github nilsbore / flexxros / src / flexxros / rosmon.py View on Github external
    @flx.reaction("!root.add_launch")
    def _add_launch(self, *events):

        for ev in events:
            with self.base_layout:
                ROSMonLaunchWidget(ev.topic)
github flexxui / flexx / flexxamples / demos / twente.py View on Github external
    @flx.reaction
    def _update_plot(self):
        smoothing = self.smoothing.value
        yy1 = data[self.month.selected_index]
        yy2 = []

        sm2 = int(smoothing / 2)
        for i in range(len(yy1)):
            val = 0
            n = 0
            for j in range(max(0, i-sm2), min(len(yy1), i+sm2+1)):
                val += yy1[j]
                n += 1
            if n == 0:
                yy2.append(yy1[i])
            else:
                yy2.append(val / n)
github nilsbore / flexxros / src / flexxros / sam_widgets.py View on Github external
    @flx.reaction("enable_cont.user_checked")
    def _enable_check(self, *events):
        self.publish(self.cont_enable_topic, {'data': bool(self.enable_cont.checked)})
github flexxui / flexx / flexxamples / howtos / control_with_keys.py View on Github external
    @flx.reaction('key_down')
    def _handle_highlighting(self, *events):
        for ev in events:
            if ev.modifiers:
                continue
            if ev.key == 'Escape':
                self.highlight_hide()
            elif ev.key == ' ':
                if self.max_selected == 0:  # space also checks if no selection
                    self.highlight_toggle_checked()
                else:
                    self.highlight_toggle_selected()
            elif ev.key == 'Enter':
                self.highlight_toggle_checked()
            elif ev.key == 'ArrowRight':
                item = self.highlight_get()
                if item and item.items:
github flexxui / flexx / flexxamples / demos / video_viewer.py View on Github external
    @flx.reaction('videolist.children*.selected')
    def on_select(self, *events):
        for ev in events:
            if ev.source.selected:
                fname = ev.source.text
                self.player.set_source(videos[fname])
github flexxui / flexx / flexxamples / howtos / leaflet.py View on Github external
    @flx.reaction
    def __handle_show_scale(self):
        if self.show_scale:
            self.map.addControl(self.scale)
        else:
            self.map.removeControl(self.scale)