我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用kivy.clock.Clock.unschedule()。
def popupDisconnect(self, instance): # Odpojení ze serveru z vyskakovacího okna (po stisku systémové klávesy zp?t v herní obrazovce) # Pouze pro OS Android self.popupExit.dismiss(instance) self.print_message("endgame\xff") self.startgame(instance) Clock.unschedule(self.heartbeat) self.sm.get_screen("StatsScreen").stats.clear_widgets() self.sm.get_screen("PartylineScreen").SLayout.clear_widgets() self.disconnect = True self.connection.loseConnection() self.connection = None self.id = False self.field.startgame = False self.sm.transition = SlideTransition(direction="right") self.sm.current = 'ConnectScreen'
def on_touch_up( self, touch ): global minUITimer global lightOffTimer if touch.grab_current is self: touch.ungrab( self ) with thermostatLock: Clock.unschedule( light_off ) if minUITimer != None: Clock.unschedule( show_minimal_ui ) minUITimer = Clock.schedule_once( show_minimal_ui, minUITimeout ) lighOffTimer = Clock.schedule_once( light_off, lightOff ) GPIO.output( lightPin, GPIO.HIGH ) self.manager.current = "thermostatUI" log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCREEN, MSG_SUBTYPE_TEXT, "Full" ) return True ############################################################################## # # # Kivy Thermostat App class # # # ##############################################################################
def on_touch_move(self, touch): if self._get_uid('cavoid') in touch.ud: return if self._touch is not touch: super(BrowsingCard, self).on_touch_move(touch) return self._get_uid() in touch.ud if touch.grab_current is not self: return True ud = touch.ud[self._get_uid()] if ud['mode'] == 'unknown': distance = abs(touch.ox - touch.x) if distance > self.scroll_distance: Clock.unschedule(self._change_touch_mode) ud['mode'] = 'scroll' else: self._offset += touch.dx return True
def on_touch_up(self, touch): if self._get_uid('cavoid') in touch.ud: return if self in [x() for x in touch.grab_list]: touch.ungrab(self) self._touch = None ud = touch.ud[self._get_uid()] if ud['mode'] == 'unknown': Clock.unschedule(self._change_touch_mode) super(BrowsingCard, self).on_touch_down(touch) Clock.schedule_once(partial(self._do_touch_up, touch), .1) else: self._start_animation() else: if self._touch is not touch and self.uid not in touch.ud: super(BrowsingCard, self).on_touch_up(touch) return self._get_uid() in touch.ud
def filter_ok(self, *args): if self.loaded == 'Yes': self.selectedtypes = [] for i in range(len(self._log_analyzer.supported_types)): if self.filter_rows[i].active: self.selectedtypes += [ list(self._log_analyzer.supported_types)[i]] if not self.selectedtypes == []: self.data_view = [ x for x in self.data_view if x["TypeID"] in self.selectedtypes] self.SetUpGrid(self.data_view, len(self.data_view), 'init') Clock.unschedule(self.check_scroll_limit) Clock.schedule_interval(self.check_scroll_limit, 0.11) self.dismiss_filter_popup() else: self.dismiss_filter_popup()
def on_touch_up( self, touch ): global minUITimer if touch.grab_current is self: touch.ungrab( self ) with thermostatLock: if minUITimer != None: Clock.unschedule( show_minimal_ui ) minUITimer = Clock.schedule_once( show_minimal_ui, minUITimeout ) self.manager.current = "thermostatUI" log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCREEN, MSG_SUBTYPE_TEXT, "Full" ) return True ############################################################################## # # # Kivy Thermostat App class # # # ##############################################################################
def toggle_state(self): try: if not self.sensorEnabled: rotation.enable() Clock.schedule_interval(self.get_readings, 1 / 20.) self.sensorEnabled = True self.compass_status = "Stop compass" else: rotation.disable() Clock.unschedule(self.get_readings) self.sensorEnabled = False self.compass_status = "Start compass" except NotImplementedError: import traceback traceback.print_exc() self.compass_status = self.NOT_IMPLEMENTED
def update(self, obj, value, delay=UPDATE_DELAY): """ To prevent overuse of update_map, each change of position triggers an update of the map after UPDATE_DELAY sec. For instance, the position of the reticule has to be updated. """ if self.map is None: return # Pause the Loader, to prevent ui blocking Loader.pause() # Reposition widgets that need to be repositioned self.reposition_executor.execute() # Trigger the map update if self.idle: self.idle = False else: Clock.unschedule(self.update_map) Clock.schedule_once(self.update_map, delay) # Resume the Loader after a short time Clock.schedule_once(MapViewer.resume_loading, 0.1)
def stop_spinning(self, *args): '''Stop spinning the progress spinner. Ignores all positional args for easy binding. If you intend to keep the spinner around, you should stop it when not using it and restart it when needed again. ''' if self._spinning: if self._next: if isinstance(self._next, Animation): self._next.cancel(self) else: self._next.cancel() Clock.unschedule(self._update) Clock.unschedule(self._rotate) self._angle_start = self._angle_end = 0 self._spinning = False
def on_events(self, *args): """?????????? ??????? ??????????.""" try: # ??????? ?????????? - ??? ???? ????????????? ?????????. _args = args[0] event = _args if isinstance(_args, str) else _args.id except AttributeError: # ??????? ??????????, ?????? ??????? - ??? ??????? ???????. event = args[1] if event == "About": # ??????? Activity About self.show_about() elif event == "on_previous" or event in (1000, 27): # ?????????? Activity self.back_screen() elif event == "JUNK FILES": # ??????? Activity JUNK FILES self.show_junk_files() # ????????? ???????? ???????? STORAGE/RAM. self.Clock.unschedule(self.calc_elliptical_length) # ?????? ???????? ????????? ???????. self.Clock.schedule_interval(self.animation_clean, 0.2) elif event == "STOP": # ????????? ???????? JUNK FILES Clock.unschedule(self.animation_clean) self.back_screen() return True
def show_image(self, interval): """??????? ?? ????? ??????????? ???????????.""" if not self.flag: return image = Image(source=self.full_path_to_load_content) button = None for name_button in [self.text_button_ok, self.text_button_no, self.text_button_cancel]: if name_button: button = self.create_button(name_button) if not button: self.create_button("Yes") self.add_widget(image) self.add_widget(Widget(size_hint=(None, .03))) self.add_widget(SettingSpacer()) self.add_widget(Widget(size_hint=(None, .03))) self.add_widget(self.box_buttons_select) self.body.content = self self.body.open() Clock.unschedule(self.show_image)
def do_quickfind(self, _, text): Clock.unschedule(self._reset_quickfind_text) text = self._quickfind_text + text self._quickfind_text = text result = self.find_index_by_text(self.quickfind_key, text, match=True) index = None selectable = False data_text = '' if result: index = result[0] selectable = True data = self.data[index] data_text = data[self.quickfind_key] if 'selectable' in data and not data['selectable']: selectable = False if selectable: self.scroll_to_index(index) delayed = lambda dt: self.children[0].select_with_touch(index) Clock.schedule_once(delayed, 0) if not selectable: self.children[0].deselect_all() Logger.info( ('AppRecycleViewQuickFind: do_quickfind: ' 'text="{}" index="{}" selectable="{}" data_text={}').format( text, index, selectable, data_text)) Clock.schedule_once( self._reset_quickfind_text, self.quickfind_reset_time)
def kb_esc(self): '''Updates self.escape_presses, quits app when reached target value''' cfocus = focus.current_focus if cfocus: focus.remove_focus() else: if self.escape_presses == 1: self.stop() else: self.display_info_toast('Double press escape to quit') self.escape_presses += 1 Clock.unschedule(self.reset_escape_presses) Clock.schedule_once(self.reset_escape_presses, 0.8)
def schedule_line_split_update(self, *args): Clock.unschedule(self._update_chars_per_line) Clock.schedule_once(self._update_chars_per_line, 0.3)
def on_state(self, _, value): if value == 'connected': Clock.schedule_interval(self.update, 0.15) elif value == 'disconnected': Clock.unschedule(self.update)
def on_progress(self, instance, value): self.making_progress = True Clock.unschedule(self.inactivity) Clock.schedule_once(self.inactivity, 1) # flag inactivity after 1 second
def on_touch_down(self, touch): self.jumping = True self.bird_image.source = "res/images/flappynormal.png" self.velocity_y = self.jump_height / (self.jump_time * 60.0) Clock.unschedule(self.stop_jumping) Clock.schedule_once(self.switch_to_normal, self.jump_time / 5.0)
def update(self): self.pos = Vector(*self.velocity) + self.pos if self.pos[1] <= 104: Clock.unschedule(self.stop_jumping) self.bird_image.source = "res/images/flappynormal.png" self.pos = (self.pos[0], 104)
def checkagain(self, dt): if self.lat!= globalloc[self.name]['lat'] or self.lon != globalloc[self.name]['lon']: self.parent.parent.add_marker(MMarker(globalloc[self.name],self.user,self.is_open)) self.detach() Clock.unschedule(self.checkagain) #print 'marker callback',self.user
def animated_diff_scale_at(self, d, x, y): self._scale_target_time = 1. self._scale_target_pos = x, y if self._scale_target_anim == False: self._scale_target_anim = True self._scale_target = d else: self._scale_target += d Clock.unschedule(self._animate_scale) Clock.schedule_interval(self._animate_scale, 1 / 60.)
def trigger_update(self, full): self._need_redraw_full = full or self._need_redraw_full Clock.unschedule(self.do_update) Clock.schedule_once(self.do_update, -1)
def prev(self, *args): # Metoda pro návrat na p?edchozí obrazovku self.root.sm.transition = SlideTransition(direction="right") self.root.sm.current = 'MainMenuScreen' Clock.unschedule(self.nextFrame)
def nextScreen(self, *args): # P?echod na další obrazovku tutorialu self.root.sm.transition = SlideTransition(direction="left") self.root.sm.current = self.root.sm.next() Clock.unschedule(self.nextFrame)
def prev(self, *args): self.root.sm.transition = SlideTransition(direction="right") self.root.sm.current = 'TutorialMove' Clock.unschedule(self.nextFrame)
def nextScreen(self, *args): self.root.sm.transition = SlideTransition(direction="left") self.root.sm.current = self.root.sm.next() Clock.unschedule(self.nextFrame)
def prev(self, *args): self.root.sm.transition = SlideTransition(direction="right") self.root.sm.current = 'TutorialDrop' Clock.unschedule(self.nextFrame)
def prev(self, *args): self.root.sm.transition = SlideTransition(direction="right") self.root.sm.current = 'TutorialSpecial' Clock.unschedule(self.nextFrame)
def prev(self, *args): self.root.sm.transition = SlideTransition(direction="right") self.root.sm.current = 'TutorialNavigate' Clock.unschedule(self.nextFrame)
def nextScreen(self, *args): self.root.sm.transition = SlideTransition(direction="left") self.root.sm.current = 'MainMenuScreen' Clock.unschedule(self.nextFrame)
def animate(self): if self.target_text: self._time = 0 Clock.unschedule(self.tick) Clock.schedule_interval(self.tick, 0)
def check_pir( pin ): global minUITimer global lightOffTimer with thermostatLock: if GPIO.input( pirPin ): log( LOG_LEVEL_INFO, CHILD_DEVICE_PIR, MSG_SUBTYPE_TRIPPED, "1" ) if minUITimer != None: Clock.unschedule( show_minimal_ui ) if lightOffTimer != None: Clock.unschedule( light_off ) minUITimer = Clock.schedule_once( show_minimal_ui, minUITimeout ) lighOffTimer = Clock.schedule_once( light_off, lightOff ) ignore = False now = datetime.datetime.now().time() if pirIgnoreFrom > pirIgnoreTo: if now >= pirIgnoreFrom or now < pirIgnoreTo: ignore = True else: if now >= pirIgnoreFrom and now < pirIgnoreTo: ignore = True if screenMgr.current == "minimalUI" and not( ignore ): screenMgr.current = "thermostatUI" log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCREEN, MSG_SUBTYPE_TEXT, "Full" ) else: log( LOG_LEVEL_DEBUG, CHILD_DEVICE_PIR, MSG_SUBTYPE_TRIPPED, "0" ) # connect with oregon scientific and check inside outside temperature
def load(self, path, filename, *args): load_failed_popup = Popup( title='Error while opening file', content=Label( text='Please select a valid file'), size_hint=( 0.8, 0.2)) if filename == []: self.dismiss_open_popup() load_failed_popup.open() else: name, extension = os.path.splitext(filename[0]) if extension == [u'.mi2log'][0]: self.loading_num = 2 self.loading_popup = Popup( title='', content=Label( text='Loading.', font_size=self.width / 25), size_hint=( 0.3, 0.2), separator_height=0, title_size=0) self.loading_popup.open() Clock.schedule_interval(self.loading, 1) Clock.unschedule(self.check_scroll_limit) self.grid.clear_widgets() with open(os.path.join(path, filename[0])) as stream: t = Thread( target=self.openFile, args=( os.path.join( path, filename[0]), self.selectedTypes)) t.start() self.dismiss_open_popup() else: self.dismiss_open_popup() load_failed_popup.open()
def search_ok(self, *args): if self.loaded == 'Yes': self.data_view = [ x for x in self.data_view if self.search_textinput.text in x["Payload"]] self.SetUpGrid(self.data_view, len(self.data_view), 'init') self.dismiss_search_popup() Clock.unschedule(self.check_scroll_limit) Clock.schedule_interval(self.check_scroll_limit, 0.11) else: self.dismiss_search_popup() # Reset # Reset the grid to the state before filtering and/or searching
def onReset(self): if self.loaded == 'Yes': self.data_view = self.data self.SetUpGrid(self.data_view, len(self.data_view), 'init') Clock.unschedule(self.check_scroll_limit) Clock.schedule_interval(self.check_scroll_limit, 0.11) # Go To # Go to the selected row
def goto_ok(self, *args): rows = len(self.data_view) num = self.goto_textinput.text if num.isdigit(): if int(num) > 0 and rows >= int(num): if int(num) >= rows - 12: self.k = rows self.dismiss_goto_popup() self.SetUpGrid(self.data, len(self.data), 'over') else: self.k = int(num) - 1 self.dismiss_goto_popup() if self.k >= rows - 24: self.SetUpGrid(self.data, len(self.data), '') else: self.SetUpGrid(self.data, len(self.data), 'up!') Clock.unschedule(self.check_scroll_limit) Clock.schedule_interval(self.check_scroll_limit, 0.11) else: self.dismiss_goto_popup() goto_failed_popup = Popup( title='Error', content=Label( text='Please write an integer in the given range'), size_hint=( 0.8, 0.2)) goto_failed_popup.open() else: self.dismiss_goto_popup() goto_failed_popup = Popup( title='Error', content=Label( text='Please write an integer in the given range'), size_hint=( 0.8, 0.2)) goto_failed_popup.open()
def start(self, button): if button == 'back': self.started = True if not self.started: self.started = True Clock.schedule_interval(self.my_callback, ANIMSPEED) self.running.text = 'Stop' else: Clock.unschedule(self.my_callback) self.started = False self.running.text = 'Start'
def check_pir( pin ): global minUITimer with thermostatLock: if GPIO.input( pirPin ): log( LOG_LEVEL_INFO, CHILD_DEVICE_PIR, MSG_SUBTYPE_TRIPPED, "1" ) if minUITimer != None: Clock.unschedule( show_minimal_ui ) minUITimer = Clock.schedule_once( show_minimal_ui, minUITimeout ) ignore = False now = datetime.datetime.now().time() if pirIgnoreFrom > pirIgnoreTo: if now >= pirIgnoreFrom or now < pirIgnoreTo: ignore = True else: if now >= pirIgnoreFrom and now < pirIgnoreTo: ignore = True if screenMgr.current == "minimalUI" and not( ignore ): screenMgr.current = "thermostatUI" log( LOG_LEVEL_DEBUG, CHILD_DEVICE_SCREEN, MSG_SUBTYPE_TEXT, "Full" ) else: log( LOG_LEVEL_DEBUG, CHILD_DEVICE_PIR, MSG_SUBTYPE_TRIPPED, "0" ) # Minimal UI Display functions and classes
def safety(self,dt): self.safety_counter += 1 safety_time = 60 if self.safety_counter == safety_time and self.startup == False: self.detirmine_layout() self.check_updates() Clock.schedule_interval(self.update_clock, 3600) Clock.unschedule(self.splash_event) return False elif self.safety_counter == safety_time and self.startup == True: return False
def exit(self, dt): Clock.unschedule(self.exit) anim = Animation(y = metrics.dp(-50), t = 'in_out_expo') anim.start(self)
def load_contacts(self, interval): if not self.dialog_load_contact: self.dialog_load_contact = dialog( title=data.string_lang_wait[:-3], text=data.string_lang_contacts_load, dismiss=False ) while _default_time() < (Clock.get_time() + MAX_TIME): self.show_contacts(self.info_contacts) self.dialog_load_contact.dismiss() Clock.unschedule(self.load_contacts)