Python kivy.clock.Clock.create_trigger() Examples
The following are 30
code examples of kivy.clock.Clock.create_trigger().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.clock.Clock
, or try the search function
.
Example #1
Source File: clock.py From Tickeys-linux with MIT License | 6 votes |
def schedule_once(self, callback, timeout=0): '''Schedule an event in <timeout> seconds. If <timeout> is unspecified or 0, the callback will be called after the next frame is rendered. :returns: A :class:`ClockEvent` instance. As opposed to :meth:`create_trigger` which only creates the trigger event, this method also schedules it. .. versionchanged:: 1.0.5 If the timeout is -1, the callback will be called before the next frame (at :meth:`tick_draw`). ''' if not callable(callback): raise ValueError('callback must be a callable, got %s' % callback) event = ClockEvent( self, False, callback, timeout, self._last_tick, _hash(callback), True) return event
Example #2
Source File: alertview.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
def editor_popup(title, content, answerCallback, size_hint=(None, None), size=(dp(500), dp(220)), hide_ok=False, auto_dismiss_time=None): def auto_dismiss(*args): popup.dismiss() def on_title(instance, title): popup.title = title content.bind(on_title=on_title) content = EditorPopup(content=content, hide_ok=hide_ok) content.bind(on_answer=answerCallback) popup = Popup(title=title, content=content, size=size, size_hint=size_hint, auto_dismiss=True, title_size=sp(18)) popup.open() if auto_dismiss_time: Clock.create_trigger(auto_dismiss, auto_dismiss_time)() return popup
Example #3
Source File: clock.py From Tickeys-linux with MIT License | 6 votes |
def schedule_once(self, callback, timeout=0): '''Schedule an event in <timeout> seconds. If <timeout> is unspecified or 0, the callback will be called after the next frame is rendered. :returns: A :class:`ClockEvent` instance. As opposed to :meth:`create_trigger` which only creates the trigger event, this method also schedules it. .. versionchanged:: 1.0.5 If the timeout is -1, the callback will be called before the next frame (at :meth:`tick_draw`). ''' if not callable(callback): raise ValueError('callback must be a callable, got %s' % callback) event = ClockEvent( self, False, callback, timeout, self._last_tick, _hash(callback), True) return event
Example #4
Source File: recycleview.py From garden.recycleview with MIT License | 6 votes |
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()
Example #5
Source File: dashboardview.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(PopupAlertView, self).__init__(**kwargs) self.minimize = None self._current_screens = {} Clock.schedule_interval(self._show_next_screen, 2.0) self.minimize_trigger = Clock.create_trigger(self._minimize, 4.0)
Example #6
Source File: main.py From kivy-smoothie-host with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(MainWindow, self).__init__(**kwargs) self.app = App.get_running_app() self._trigger = Clock.create_trigger(self.async_get_display_data) self._q = queue.Queue() self.config = self.app.config self.last_path = self.config.get('General', 'last_gcode_path') self.paused = False self.last_line = 0 # print('font size: {}'.format(self.ids.log_window.font_size)) # Clock.schedule_once(self.my_callback, 2) # hack to overcome the page layout not laying out initially
Example #7
Source File: carousel.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._trigger_position_visible_slides = Clock.create_trigger( self._position_visible_slides, -1) super(Carousel, self).__init__(**kwargs) self._skip_slide = None
Example #8
Source File: rst.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._trigger_load = Clock.create_trigger(self._load_from_text, -1) self._parser = rst.Parser() self._settings = frontend.OptionParser( components=(rst.Parser, )).get_default_values() super(RstDocument, self).__init__(**kwargs)
Example #9
Source File: treeview.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._trigger_layout = Clock.create_trigger(self._do_layout, -1) super(TreeView, self).__init__(**kwargs) tvlabel = TreeViewLabel(text='Root', is_open=True, level=0) for key, value in self.root_options.items(): setattr(tvlabel, key, value) self._root = self.add_node(tvlabel, None) self.bind( pos=self._trigger_layout, size=self._trigger_layout, indent_level=self._trigger_layout, indent_start=self._trigger_layout) self._trigger_layout()
Example #10
Source File: accordion.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._trigger_title = Clock.create_trigger(self._update_title, -1) self._anim_collapse = None super(AccordionItem, self).__init__(**kwargs) self.bind(title=self._trigger_title, title_template=self._trigger_title, title_args=self._trigger_title) self._trigger_title()
Example #11
Source File: accordion.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): super(Accordion, self).__init__(**kwargs) self._trigger_layout = Clock.create_trigger(self._do_layout, -1) self.bind( orientation=self._trigger_layout, children=self._trigger_layout, size=self._trigger_layout, pos=self._trigger_layout, min_space=self._trigger_layout)
Example #12
Source File: layout.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): if self.__class__ == Layout: raise Exception('The Layout class cannot be used.') self._trigger_layout = Clock.create_trigger(self.do_layout, -1) super(Layout, self).__init__(**kwargs)
Example #13
Source File: kinetic.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self.history = [] self.trigger_velocity_update = Clock.create_trigger( self.update_velocity, 0) super(KineticEffect, self).__init__(**kwargs)
Example #14
Source File: loader.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self): self._loading_image = None self._error_image = None self._num_workers = 2 self._max_upload_per_frame = 2 self._paused = False self._resume_cond = threading.Condition() self._q_load = deque() self._q_done = deque() self._client = [] self._running = False self._start_wanted = False self._trigger_update = Clock.create_trigger(self._update)
Example #15
Source File: clock.py From Tickeys-linux with MIT License | 5 votes |
def schedule_interval(self, callback, timeout): '''Schedule an event to be called every <timeout> seconds. :returns: A :class:`ClockEvent` instance. As opposed to :meth:`create_trigger` which only creates the trigger event, this method also schedules it. ''' if not callable(callback): raise ValueError('callback must be a callable, got %s' % callback) event = ClockEvent( self, True, callback, timeout, self._last_tick, _hash(callback), True) return event
Example #16
Source File: dashboardview.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, status_pump, track_manager, rc_api, rc_config, databus, settings, **kwargs): self._initialized = False super(DashboardView, self).__init__(**kwargs) dashboard_state = self._dashboard_state = DashboardState() self._alert_engine = AlertEngine(self._dashboard_state) self._dashboard_factory = DashboardFactory(dashboard_state, databus, settings, track_manager, status_pump) self.register_event_type('on_tracks_updated') self.register_event_type('on_config_updated') self.register_event_type('on_config_written') self._screens = [] self._current_screen = None self._loaded_screens = {} self._status_pump = status_pump self._databus = databus self._settings = settings self._track_manager = track_manager self._rc_api = rc_api self._rc_config = rc_config self._alert_widgets = {} self._dismiss_popup_trigger = Clock.create_trigger(self._dismiss_popup, DashboardView._POPUP_DISMISS_TIMEOUT_LONG) self._popup = None self._track_config = None self._gps_sample = GpsSample() status_pump.add_listener(self.status_updated) self.alert_bar_height = 0 self._start_alert_engine() self._current_sample = None
Example #17
Source File: gauge.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(CustomizableGauge, self).__init__(**kwargs) self._dismiss_customization_popup_trigger = Clock.create_trigger(self._dismiss_popup, Gauge.POPUP_DISMISS_TIMEOUT_LONG)
Example #18
Source File: trackbuilder.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def _init_status_monitor(self): self._status_decay = Clock.create_trigger(self._on_status_decay, TrackMapCreatorScreen.STATUS_LINGER_DURATION_SEC) self._status_decay()
Example #19
Source File: flyinpanel.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): Builder.load_string(FLYIN_PANEL_LAYOUT) super(FlyinPanel, self).__init__(**kwargs) self.hide_decay = Clock.create_trigger(lambda dt: self.hide(), self.SESSION_HIDE_DELAY) Window.bind(mouse_pos=self.on_mouse_pos) Window.bind(on_motion=self.on_motion) Clock.schedule_once(lambda dt: self.show()) self._shown_at = None
Example #20
Source File: iconbutton.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(FadeableWidget, self).__init__(**kwargs) self._current_alpha = None self.brighten_mode = True self._schedule_fade = Clock.create_trigger(self._fade_back, FadeableWidget.FADE_DELAY) self._schedule_step = Clock.create_trigger(self._fade_step, FadeableWidget.FADE_INTERVAL)
Example #21
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): super(Graph, self).__init__(**kwargs) with self.canvas: self._fbo = Fbo(size=self.size) self._marker_color = Color(self.marker_color) self._marker = Line() 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) 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()
Example #22
Source File: __init__.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
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() # plot specific y axis min/max self.ymin = None self.ymax = None # 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.
Example #23
Source File: __init__.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
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
Example #24
Source File: treeview.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._trigger_layout = Clock.create_trigger(self._do_layout, -1) super(TreeView, self).__init__(**kwargs) tvlabel = TreeViewLabel(text='Root', is_open=True, level=0) for key, value in self.root_options.items(): setattr(tvlabel, key, value) self._root = self.add_node(tvlabel, None) self.bind( pos=self._trigger_layout, size=self._trigger_layout, indent_level=self._trigger_layout, indent_start=self._trigger_layout) self._trigger_layout()
Example #25
Source File: __init__.py From kivy-smoothie-host with GNU General Public License v3.0 | 5 votes |
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, x_ticks_angle=t) self.bind(tick_color=tc, background_color=tc, border_color=tc) self._trigger()
Example #26
Source File: __init__.py From kivy-smoothie-host with GNU General Public License v3.0 | 5 votes |
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()
Example #27
Source File: colorpickercustom.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def _trigger_update_clr(self, mode, clr_idx, text): self._upd_clr_list = mode, clr_idx, text ev = self._update_clr_ev if ev is None: ev = self._update_clr_ev = Clock.create_trigger(self._update_clr) ev()
Example #28
Source File: colorpickercustom.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def _trigger_update_hex(self, text): self._upd_hex_list = text ev = self._update_hex_ev if ev is None: ev = self._update_hex_ev = Clock.create_trigger(self._update_hex) ev()
Example #29
Source File: urlrequest.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, url, on_success=None, on_redirect=None, on_failure=None, on_error=None, on_progress=None, req_body=None, req_headers=None, chunk_size=8192, timeout=None, method=None, decode=True, debug=False, file_path=None): super(UrlRequest, self).__init__() self._queue = deque() self._trigger_result = Clock.create_trigger(self._dispatch_result, 0) self.daemon = True self.on_success = WeakMethod(on_success) if on_success else None self.on_redirect = WeakMethod(on_redirect) if on_redirect else None self.on_failure = WeakMethod(on_failure) if on_failure else None self.on_error = WeakMethod(on_error) if on_error else None self.on_progress = WeakMethod(on_progress) if on_progress else None self.decode = decode self.file_path = file_path self._debug = debug self._result = None self._error = None self._is_finished = False self._resp_status = None self._resp_headers = None self._resp_length = -1 self._chunk_size = chunk_size self._timeout = timeout self._method = method #: Url of the request self.url = url #: Request body passed in __init__ self.req_body = req_body #: Request headers passed in __init__ self.req_headers = req_headers # save our request to prevent GC g_requests.append(self) self.start()
Example #30
Source File: clock.py From Tickeys-linux with MIT License | 5 votes |
def create_trigger(self, callback, timeout=0): '''Create a Trigger event. Check module documentation for more information. :returns: A :class:`ClockEvent` instance. To schedule the callback of this instance, you can call it. .. versionadded:: 1.0.5 ''' ev = ClockEvent(self, False, callback, timeout, 0, _hash(callback)) ev.release() return ev