Python kivy.clock.Clock 模块,create_trigger() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用kivy.clock.Clock.create_trigger()

项目:KivyNBT    作者:Kovak    | 项目源码 | 文件源码
def __init__(self, data_dir, name, do_date=False, do_hour=False, **kwargs):
        super(DBInterface, self).__init__(**kwargs)

        self.ensure_dir(data_dir)
        if do_date:
            if do_hour:
                date = self.convert_time_to_json_ymdh(self.get_time())
            else:
                date = self.convert_time_to_json_ymd(self.get_time())
            json_name = data_dir + name + '-' + date + '.json'
            reset_json_name = (
                data_dir + name + '-' + date + '-reset_timers.json')
        else:
            json_name = data_dir + name + '.json'
            reset_json_name = data_dir + name + '-reset_timers.json'
        self.data = data = JsonStore(json_name)
        self.reset_timers = reset_timers = JsonStore(reset_json_name)
        self.sync = Clock.create_trigger(self.trigger_sync)
        self.check_reset(0.)
        Clock.schedule_interval(self.check_reset, 60.)
项目:displayminion    作者:cedarsuite    | 项目源码 | 文件源码
def prep(self, e, r):
        self.state = 'registered'
        self.trigger_event('registered')

        self.debug('Registered')

        self.meteor.on('added', self.added)
        self.meteor.on('changed', self.changed)

        self.minion = self.meteor.find_one('minions', selector = {'_id': self._id});
        self.stage = self.meteor.find_one('stages', selector = {'_id': self.minion['stage']})

        self.update_minion_settings(self.minion)

        Clock.create_trigger(self.update_layers)()
        Clock.schedule_once(self.update_minion_blocks, 0)

        self.ready = True
项目:KivyTrek    作者:peterLaurence    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        self._refresh_flags = dict(self._refresh_flags)
        self._refresh_trigger = Clock.create_trigger(self.refresh_views, -1)

        if self._layout_manager is None:
            self.layout_manager = LinearRecycleLayoutManager()
        if self._adapter is None:
            self.adapter = RecycleAdapter()
        super(RecycleView, self).__init__(**kwargs)
        if self._container is None:
            self.container = RecycleViewLayout(size_hint=(None, None))

        fbind = self.fbind if _kivy_1_9_1 else self.fast_bind
        fbind('size', self.ask_refresh_from_data, extent='data_size')
        fbind('scroll_x', self.ask_refresh_viewport)
        fbind('scroll_y', self.ask_refresh_viewport)
        self._refresh_trigger()
项目:Wall-EEG    作者:neurotechuoft    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Graph, self).__init__(**kwargs)

        with self.canvas:
            self._fbo = Fbo(size=self.size,
                            with_stencilbuffer=self._with_stencilbuffer)

        with self._fbo:
            self._background_color = Color(*self.background_color)
            self._background_rect = Rectangle(size=self.size)
            self._mesh_ticks_color = Color(*self.tick_color)
            self._mesh_ticks = Mesh(mode='lines')
            self._mesh_rect_color = Color(*self.border_color)
            self._mesh_rect = Mesh(mode='line_strip')

        with self.canvas:
            Color(1, 1, 1)
            self._fbo_rect = Rectangle(size=self.size,
                                       texture=self._fbo.texture)

        mesh = self._mesh_rect
        mesh.vertices = [0] * (5 * 4)
        mesh.indices = range(5)

        self._plot_area = StencilView()
        self.add_widget(self._plot_area)

        t = self._trigger = Clock.create_trigger(self._redraw_all)
        ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
        tc = self._trigger_color = Clock.create_trigger(self._update_colors)

        self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
                  y_grid=ts, draw_border=ts)
        self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
                  xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
                  y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
                  font_size=t, label_options=t)
        self.bind(tick_color=tc, background_color=tc, border_color=tc)
        self._trigger()
项目:Wall-EEG    作者:neurotechuoft    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Plot, self).__init__(**kwargs)
        self.ask_draw = Clock.create_trigger(self.draw)
        self.bind(params=self.ask_draw, points=self.ask_draw)
        self._drawings = self.create_drawings()

    # this function is called by graph whenever any of the parameters
    # change. The plot should be recalculated then.
    # log, min, max indicate the axis settings.
    # size a 4-tuple describing the bounding box in which we can draw
    # graphs, it's (x0, y0, x1, y1), which correspond with the bottom left
    # and top right corner locations, respectively.
项目:caltrac    作者:shiburizu    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Graph, self).__init__(**kwargs)

        with self.canvas:
            self._fbo = Fbo(size=self.size, with_stencilbuffer=self._with_stencilbuffer)

        with self._fbo:
            self._background_color = Color(*self.background_color)
            self._background_rect = Rectangle(size=self.size)
            self._mesh_ticks_color = Color(*self.tick_color)
            self._mesh_ticks = Mesh(mode='lines')
            self._mesh_rect_color = Color(*self.border_color)
            self._mesh_rect = Mesh(mode='line_strip')

        with self.canvas:
            Color(1, 1, 1)
            self._fbo_rect = Rectangle(size=self.size, texture=self._fbo.texture)

        mesh = self._mesh_rect
        mesh.vertices = [0] * (5 * 4)
        mesh.indices = range(5)

        self._plot_area = StencilView()
        self.add_widget(self._plot_area)

        t = self._trigger = Clock.create_trigger(self._redraw_all)
        ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
        tc = self._trigger_color = Clock.create_trigger(self._update_colors)

        self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
                  y_grid=ts, draw_border=ts)
        self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
                  xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
                  y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
                  font_size=t, label_options=t)
        self.bind(tick_color=tc, background_color=tc, border_color=tc)
        self._trigger()
项目:caltrac    作者:shiburizu    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Plot, self).__init__(**kwargs)
        self.ask_draw = Clock.create_trigger(self.draw)
        self.bind(params=self.ask_draw, points=self.ask_draw)
        self._drawings = self.create_drawings()

    # this function is called by graph whenever any of the parameters
    # change. The plot should be recalculated then.
    # log, min, max indicate the axis settings.
    # size a 4-tuple describing the bounding box in which we can draw
    # graphs, it's (x0, y0, x1, y1), which correspond with the bottom left
    # and top right corner locations, respectively.
项目:KivyNBT    作者:Kovak    | 项目源码 | 文件源码
def __init__(self, font_ramp, name, **kwargs):
        super(RampGroup, self).__init__(**kwargs)
        self.tracked_labels = []
        self.font_ramp = font_ramp
        self.name = name
        self.current_style = font_ramp[-1]
        self._test_label = FlatLabel()
        self._cache = {}
        self.max_iterations = 5
        self.trigger_fit_check = Clock.create_trigger(
            self.check_fit_for_all_labels)
项目:KivyNBT    作者:Kovak    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(ItemSlotWidget, self).__init__(**kwargs)
        self.file_name = None
        self.drop_chance_wid = None
        Clock.schedule_once(self.draw_widget)
        self.draw_trigger = Clock.create_trigger(self.draw_widget)
项目:Blogs-Posts-Tutorials    作者:kiok46    | 项目源码 | 文件源码
def __init__(self, **kw):
        self._trigger_genitems = Clock.create_trigger(self._genitems, -1)
        self.bind(min=self._trigger_genitems,
                  max=self._trigger_genitems,
                  multiples_of=self._trigger_genitems)
        super(CircularNumberPicker, self).__init__(**kw)
        self.selected = self.min
        self.bind(selected=self.on_selected,
                  pos=self.on_selected,
                  size=self.on_selected)

        cx = self.center_x + self.padding[0] - self.padding[2]
        cy = self.center_y + self.padding[3] - self.padding[1]
        sx, sy = self.pos_for_number(self.selected)
        epos = [i - (self.delta_radii * self.number_size_factor) for i in (sx, sy)]
        esize = [self.delta_radii * self.number_size_factor * 2] * 2
        dsize = [i * .3 for i in esize]
        dpos = [i + esize[0] / 2. - dsize[0] / 2. for i in epos]
        csize = [i * .05 for i in esize]
        cpos = [i - csize[0] / 2. for i in (cx, cy)]
        dot_alpha = 0 if self.selected % self.multiples_of == 0 else 1
        color = list(self.selector_color)

        with self.canvas:
            self._selection_color = Color(*(color + [self.selector_alpha]))
            self._selection_circle = Ellipse(pos=epos, size=esize)
            self._selection_line = Line(points=[cx, cy, sx, sy], width=dp(1.25))
            self._selection_dot_color = Color(*(color + [dot_alpha]))
            self._selection_dot = Ellipse(pos=dpos, size=dsize)
            self._center_color = Color(*self.color)
            self._center_dot = Ellipse(pos=cpos, size=csize)

        self.bind(selector_color=lambda ign, u: setattr(self._selection_color, "rgba", u + [self.selector_alpha]))
        self.bind(selector_color=lambda ign, u: setattr(self._selection_dot_color, "rgb", u))
        self.bind(selector_color=lambda ign, u: self.dot_is_none())
        self.bind(color=lambda ign, u: setattr(self._center_color, "rgb", u))
        Clock.schedule_once(self._genitems)
        Clock.schedule_once(self.on_selected)  # Just to make sure pos/size are set
项目:iotdm-pyclient    作者:peterchauyw    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(BrowsingCard, self).__init__(**kwargs)
        self.controller = kwargs['controller']
        self._trigger_position_visible_slides = Clock.create_trigger(
                self._position_visible_slides, -1)
项目:mobileinsight-mobile    作者:mobile-insight    | 项目源码 | 文件源码
def __init__(self, **kw):
        self._trigger_genitems = Clock.create_trigger(self._genitems, -1)
        self.bind(min=self._trigger_genitems,
                  max=self._trigger_genitems,
                  multiples_of=self._trigger_genitems)
        super(CircularNumberPicker, self).__init__(**kw)
        self.selected = self.min
        self.bind(selected=self.on_selected,
                  pos=self.on_selected,
                  size=self.on_selected)

        cx = self.center_x + self.padding[0] - self.padding[2]
        cy = self.center_y + self.padding[3] - self.padding[1]
        sx, sy = self.pos_for_number(self.selected)
        epos = [i - (self.delta_radii * self.number_size_factor) for i in (sx, sy)]
        esize = [self.delta_radii * self.number_size_factor * 2] * 2
        dsize = [i * .3 for i in esize]
        dpos = [i + esize[0] / 2. - dsize[0] / 2. for i in epos]
        csize = [i * .05 for i in esize]
        cpos = [i - csize[0] / 2. for i in (cx, cy)]
        dot_alpha = 0 if self.selected % self.multiples_of == 0 else 1
        color = list(self.selector_color)

        with self.canvas:
            self._selection_color = Color(*(color + [self.selector_alpha]))
            self._selection_circle = Ellipse(pos=epos, size=esize)
            self._selection_line = Line(points=[cx, cy, sx, sy], width=dp(1.25))
            self._selection_dot_color = Color(*(color + [dot_alpha]))
            self._selection_dot = Ellipse(pos=dpos, size=dsize)
            self._center_color = Color(*self.color)
            self._center_dot = Ellipse(pos=cpos, size=csize)

        self.bind(selector_color=lambda ign, u: setattr(self._selection_color, "rgba", u + [self.selector_alpha]))
        self.bind(selector_color=lambda ign, u: setattr(self._selection_dot_color, "rgb", u))
        self.bind(selector_color=lambda ign, u: self.dot_is_none())
        self.bind(color=lambda ign, u: setattr(self._center_color, "rgb", u))
        Clock.schedule_once(self._genitems)
        Clock.schedule_once(self.on_selected)  # Just to make sure pos/size are set
项目:Exode    作者:sne3ks    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Graph, self).__init__(**kwargs)

        with self.canvas:
            self._fbo = Fbo(size=self.size, with_stencilbuffer=self._with_stencilbuffer)

        with self._fbo:
            self._background_color = Color(*self.background_color)
            self._background_rect = Rectangle(size=self.size)
            self._mesh_ticks_color = Color(*self.tick_color)
            self._mesh_ticks = Mesh(mode='lines')
            self._mesh_rect_color = Color(*self.border_color)
            self._mesh_rect = Mesh(mode='line_strip')

        with self.canvas:
            Color(1, 1, 1)
            self._fbo_rect = Rectangle(size=self.size, texture=self._fbo.texture)

        mesh = self._mesh_rect
        mesh.vertices = [0] * (5 * 4)
        mesh.indices = range(5)

        self._plot_area = StencilView()
        self.add_widget(self._plot_area)

        t = self._trigger = Clock.create_trigger(self._redraw_all)
        ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
        tc = self._trigger_color = Clock.create_trigger(self._update_colors)

        self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
                  y_grid=ts, draw_border=ts)
        self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
                  xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
                  y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
                  font_size=t, label_options=t)
        self.bind(tick_color=tc, background_color=tc, border_color=tc)
        self._trigger()
项目:Exode    作者:sne3ks    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Plot, self).__init__(**kwargs)
        self.ask_draw = Clock.create_trigger(self.draw)
        self.bind(params=self.ask_draw, points=self.ask_draw)
        self._drawings = self.create_drawings()

    # this function is called by graph whenever any of the parameters
    # change. The plot should be recalculated then.
    # log, min, max indicate the axis settings.
    # size a 4-tuple describing the bounding box in which we can draw
    # graphs, it's (x0, y0, x1, y1), which correspond with the bottom left
    # and top right corner locations, respectively.
项目:displayminion    作者:cedarsuite    | 项目源码 | 文件源码
def changed(self, collection, _id, fields, cleared):
        if not self.ready: return

        if collection == 'minions' and _id == self._id:
            self.minion = self.meteor.find_one('minions', selector = {'_id': self._id});
            self.update_minion_settings(self.minion)

        if collection == 'stages' and _id == self.minion['stage']:
            self.stage = self.meteor.find_one('stages', selector = {'_id': self.minion['stage']})
            Clock.create_trigger(self.update_layers)()
项目:kivy_gosh    作者:mcroni    | 项目源码 | 文件源码
def __init__(self, **kw):
        self._trigger_genitems = Clock.create_trigger(self._genitems, -1)
        self.bind(min=self._trigger_genitems,
                  max=self._trigger_genitems,
                  multiples_of=self._trigger_genitems)
        super(CircularNumberPicker, self).__init__(**kw)
        self.selected = self.min
        self.bind(selected=self.on_selected,
                  pos=self.on_selected,
                  size=self.on_selected)

        cx = self.center_x + self.padding[0] - self.padding[2]
        cy = self.center_y + self.padding[3] - self.padding[1]
        sx, sy = self.pos_for_number(self.selected)
        epos = [i - (self.delta_radii * self.number_size_factor) for i in (sx, sy)]
        esize = [self.delta_radii * self.number_size_factor * 2] * 2
        dsize = [i * .3 for i in esize]
        dpos = [i + esize[0] / 2. - dsize[0] / 2. for i in epos]
        csize = [i * .05 for i in esize]
        cpos = [i - csize[0] / 2. for i in (cx, cy)]
        dot_alpha = 0 if self.selected % self.multiples_of == 0 else 1
        color = list(self.selector_color)

        with self.canvas:
            self._selection_color = Color(*(color + [self.selector_alpha]))
            self._selection_circle = Ellipse(pos=epos, size=esize)
            self._selection_line = Line(points=[cx, cy, sx, sy], width=dp(1.25))
            self._selection_dot_color = Color(*(color + [dot_alpha]))
            self._selection_dot = Ellipse(pos=dpos, size=dsize)
            self._center_color = Color(*self.color)
            self._center_dot = Ellipse(pos=cpos, size=csize)

        self.bind(selector_color=lambda ign, u: setattr(self._selection_color, "rgba", u + [self.selector_alpha]))
        self.bind(selector_color=lambda ign, u: setattr(self._selection_dot_color, "rgb", u))
        self.bind(selector_color=lambda ign, u: self.dot_is_none())
        self.bind(color=lambda ign, u: setattr(self._center_color, "rgb", u))
        Clock.schedule_once(self._genitems)
        Clock.schedule_once(self.on_selected)  # Just to make sure pos/size are set
项目:zipper    作者:richarddun    | 项目源码 | 文件源码
def on_touch_up(self, touch):
        """
        kivy on_touch_up handle, to clear prep_zip values and cease action when mouse is released
        :param touch: kivy touch input
        :return: none
        """
        self.touching = False
        self.coldir = 'n'
        trigger = Clock.create_trigger(self.zip)
        trigger()
项目:KivyTrek    作者:peterLaurence    | 项目源码 | 文件源码
def __init__(self, default_reticule, **kwargs):
        super(MapBoard, self).__init__(**kwargs)

        # Create the map viewer
        self.mapviewer = MapViewer(**kwargs)
        self.add_widget(self.mapviewer)

        # Load the reticule
        self.load_reticule(default_reticule)

        # Create compass button
        self.compass_button = CompassButton()
        self.add_widget(self.compass_button)

        # Add a reticule for calibration
        self.reticule_calib = Builder.load_file('ui/ScatterReticule.kv')

        # Create center_on_pos button
        self.load_center_on_pos()

        # Create path button
        path_button = PathButton()
        path_button.bind(on_press=self.mapviewer.toggle_tracking_path)
        self.add_widget(path_button)

        # Create the distance to center button
        self.dist_to_center_widget = None
        self.dist_to_center_visible =False
        self._dist_to_center_update_trigger = Clock.create_trigger(
            lambda x: self.dist_to_center_widget.set_distance(self.mapviewer.get_dist_to_center()), timeout=0.1)
        self.load_dist_to_center_button()