def on_leave(self): Clock.unschedule(self.update) self.player1.score = 0 self.player2.score = 0 for c in self.pongfloat.children: if isinstance(c, WinLabel): self.pongfloat.remove_widget(c)
def reset_words(self): Clock.unschedule(self.add_word) for content_widget in self.text_content_widgets: content_widget.text = _example_title_text # initialize words generator self.words = (word for word in _example_text.split()) self.add_word()
def delete_clock(self, touch, *args): # TODO: Fix touch_up passing through when popup dismissed. try: Clock.unschedule(touch.ud['event']) except KeyError: Logger.exception( 'Application: Touch up passed through and unscheduled clock event could not be unscheduled. A bug...')
def add_term_widget(self, cfg): layout = TermBoxLayout() ti = TabbedPanelHeader() ti.text = ' '.join([str(len(self.root_widget.term_panel.tab_list) + 1), 'Terminal']) ti.content = layout ti.size_hint = (1,1) self.root_widget.term_panel.add_widget(ti) session = create_session(cfg, self.create_terminal(cfg)) term_widget = TermTextInput(session) term_widget.size_hint = (1, 1) term_widget.pos_hint = {'center_y':.5, 'center_x':.5} layout.add_widget(term_widget) layout.term_widget = term_widget ti.term_widget = term_widget ti.session = session ti.session.term_widget = term_widget ti.session.terminal.term_widget = term_widget Clock.unschedule(self.root_widget.term_panel._load_default_tab_content) self.switch_to_tab(ti) conn_str = cfg.get_conn_str() if conn_str in self.conn_history: self.conn_history.remove(conn_str) self.conn_history.insert(0, conn_str)
def test_unschedule_after_tick(self): from kivy.clock import Clock Clock.schedule_once(callback, 5.) Clock.tick() Clock.unschedule(callback) Clock.tick() self.assertEqual(counter, 0)
def use(self, direction, active): if active and self.manager.current == 'game': Clock.unschedule(self.func) self.func = partial(self.move, direction) Clock.schedule_interval(self.func, self.player_speed) else: Clock.unschedule(self.func)
def next(self,*largs): Clock.unschedule(self.next) if(self.screenManager.current == 'page1'): next = 'page2' page = self.page2 else: next = 'page1' page = self.page1 self.index += 1 if self.index == len(self.photos): self.index = 0 page.source = self.photos[self.index] page.background.scale = 1.0 self.screenManager.transition = self.transitions[random.randint(0, len(self.transitions) -1)] self.screenManager.current = next anim = Animation( scale=page.background.scale*1.3, duration=15.0 ) Clock.schedule_once(self.next, 10) anim.start(page.background)
def on_focus(self, instance, value, *largs): win = self._win if not win: self._win = win = self.get_root_window() if not win: # we got argument, it could be the previous schedule # cancel focus. if len(largs): Logger.warning('Textinput: ' 'Cannot focus the element, unable to get root window') return else: Clock.schedule_once(partial(self.on_focus, self, value), 0) return if value: keyboard = win.request_keyboard(self._keyboard_released, self) self._keyboard = keyboard keyboard.bind( on_key_down=self._keyboard_on_key_down, on_key_up=self._keyboard_on_key_up) Clock.schedule_interval(self._do_blink_cursor, 1 / 2.) else: keyboard = self._keyboard keyboard.unbind( on_key_down=self._keyboard_on_key_down, on_key_up=self._keyboard_on_key_up) keyboard.release() self.cancel_selection() Clock.unschedule(self._do_blink_cursor) self._win = None
def handle_trash_talk(self, trigger): if trigger in [Trigger.GAME_END, Trigger.GAME_PAUSE]: Clock.unschedule(self.trash) if trigger in [Trigger.GAME_START, Trigger.GAME_RESUME, Trigger.GOAL]: Clock.unschedule(self.trash) Clock.schedule_interval(self.trash, random.randint(settings.TRASH_MIN_DELAY, settings.TRASH_MAX_DELAY))
def reinitscreen(self, nxt_cur): # No answer given yet if nxt_cur == 0: print("Reinit: no answer") self.next_kanji = False self.answered = 0 self.master_kanji.story_show = False # Correct answer elif nxt_cur == 1: print("Reinit: correct") self.next_kanji = True self.answered = 1 self.master_kanji.story_show = True Clock.unschedule(self.cb_disablesend) self.disablesend(False) # Wrong answer else: print("Reinit: wrong") self.next_kanji = False self.answered = 1 self.master_kanji.story_show = True # Answers bold in self.story #self.master_kanji.story_bold() # sKanji buttons (Clock.schedule to call this function after .kv initialisation) Clock.schedule_once(lambda dt: self.changeSKanji())
def restart_button(obj): #reset game self.removeScore() for k in self.asteroidList: self.remove_widget(k) self.ship.xpos = Window.width*0.25 self.ship.ypos = Window.height*0.5 self.minProb = 1780 self.asteroidScore = 0 self.asteroidList = [] self.parent.remove_widget(restartButton) Clock.unschedule(self.update) Clock.schedule_interval(self.update, 1.0/60.0) restartButton.size = (Window.width*.3,Window.width*.1) restartButton.pos = Window.width*0.5-restartButton.width/2, Window.height*0.53 restartButton.bind(on_release=restart_button) #we will want to bind the parent to listen for things from certain bubbles #*** It's important that the parent get the button so you can click on it #otherwise you can't click through the main game's canvas self.parent.add_widget(restartButton) #now draw the score widget self.showScore()
def ansresult(self, instance): # invokes by pressing button Answer # stops all clock shedules Clock.unschedule(self.time_label.update) Clock.unschedule(self.timeend) # checks whether user gave right answer # and invokes window with answering result for i in self.togglebuttonlist: if i.text == self.states[self.guess_state]: i.background_color = (0, 1, 0, 1) if i.state == "down": self.score += 1 if self.score % 10 == 0: self.level += 1 text = "Congratulations! Your score is %d" % (self.score) btnaction = self.nextround else: text = "You lost!" btnaction = self.gameover content = Button(text=text) self.answerresult = Popup(title="", content=content, size_hint=(.8, .5), auto_dismiss=False) content.bind(on_press=btnaction) self.answerresult.open()
def on_touch_move(self, touch, *args): if ( touch.ud['menu_timeout'] and squared_dist(touch.pos, touch.opos) > self.cancel_distance ** 2 ): Clock.unschedule(touch.ud['menu_timeout']) return super(MenuSpawner, self).on_touch_move(touch, *args)
def bam(self, jewels, alltogether=False, **kwargs): # first explode all the jewel d = 0 board = self.board rows = [] nosound = 'nosound' in kwargs for jewel in jewels: ix, iy = jewel.ix, jewel.iy board[ix][iy] = None func = jewel.explode_nosound if nosound else jewel.explode Clock.schedule_once(func, d) if not alltogether: d += .2 if ix not in rows: rows.append(ix) self.blocked_rows[ix] += 1 if alltogether: d = 0.2 # more combo! self.app.score_combo += 1 ix = jewels[-1].ix iy = jewels[-1].iy self.app.add_score(ix, iy, 'combo', 1) Clock.unschedule(self.reset_combo) Clock.schedule_once(self.reset_combo, d + 1.) Clock.schedule_once(partial(self.unblock_rows, rows), d)
def gameover(self): survival = time() - self.starttime self.clear_widgets() Clock.unschedule(self.update) Clock.unschedule(self.difficultify) self.GameOverNote(survival) self.fanfare.play()
def info_dismiss(self, *largs): """Handler when the detailed task info popup is closed.""" Logger.debug("CoreTask: Hiding info") self.info_showing = False # Stop requesting for output Clock.unschedule(self.request_output)
def set_status(self, value): """Setter for the task's status. Binds and unbinds buttons.""" if self._status == value: return Logger.debug("CoreTask: Set status to %s" % value) self._status = value self.label.text = '%s\nStatus: %s' % (self.name, value) self.update_title() if not self.info_built: return if self.status == "Running": self.unbind_button(self.pause_button) self.pause_button.image = self.manyman.settings['task_pause_image'] self.bind_button(self.stop_button, self.stop) self.bind_button(self.pause_button, self.pause) self.bind_button(self.move_button, self.move) self.bind_button(self.kill_button, self.kill) elif self.status == "Stopped": self.unbind_button(self.pause_button) self.pause_button.image = \ self.manyman.settings['task_resume_image'] self.bind_button(self.pause_button, self.resume) elif self.status == "Finished" or self.status == "Killed": Clock.unschedule(self.request_output)
def clear_selection(self,*kwargs): '''This function takes away the highlight and also nullifies the self.widget''' self.widget = None #We have to stop highlighing Clock.unschedule(self.highlight_at) self.grect.size = (0, 0)
def on_touch_up(self, touch): if self._get_uid('svavoid') in touch.ud: return if self in [x() for x in touch.grab_list]: touch.ungrab(self) self._touch = None uid = self._get_uid() ud = touch.ud[uid] if self.do_scroll_x and self.effect_x: if not touch.ud.get('in_bar_x', False) and\ self.scroll_type != ['bars']: self.effect_x.stop(touch.x) if self.do_scroll_y and self.effect_y and\ self.scroll_type != ['bars']: if not touch.ud.get('in_bar_y', False): self.effect_y.stop(touch.y) if ud['mode'] == 'unknown': # we must do the click at least.. # only send the click if it was not a click to stop # autoscrolling if not ud['user_stopped']: super(ScrollView, self).on_touch_down(touch) Clock.schedule_once(partial(self._do_touch_up, touch), .2) Clock.unschedule(self._update_effect_bounds) Clock.schedule_once(self._update_effect_bounds) else: if self._touch is not touch and self.uid not in touch.ud: super(ScrollView, self).on_touch_up(touch) # if we do mouse scrolling, always accept it if 'button' in touch.profile and touch.button.startswith('scroll'): return True return self._get_uid() in touch.ud
def inertial_translation(self, time): #print abs(self.dx), 0.003 * self.width, abs(self.dy), 0.003 * self.height if abs(self.dx) > 0.003 * self.width and abs(self.dy) > 0.003 * self.height: self.pos = [self.x + self.dx, self.y + self.dy] self.center = Utilities.clamp(*self.center) # Todo: this needs to be removed to a gloabl class! # If the item gets near the edge, kill the schedule function on it, as it will just waste cycles if self.center[0]-15 < 0 or\ self.center[0]+15 > Utilities.window_width or \ self.center[1] -15 < 0 or \ self.center[1] + 15 > Utilities.window_height: #self.dx *= 0.1 #self.dy *= 0.1 Clock.unschedule(self.inertial_translation) return # friction (1= glides forever)/ rate of decay try: if self.linked_children: self.dx *= 0.8 self.dy *= 0.8 else: self.dx *= 0.9 self.dy *= 0.9 except Exception, e: self.dx *= 0.93 self.dy *= 0.93
def on_touch_up(self, touch): if touch.grab_current is not self: return False handled = super(DwellOnScatter, self).on_touch_up(touch) if self.ignore_dwell is not True: #if self.collide_point(touch.x, touch.y): self.dwell_started_counter = 0 if self.dwell_started_by_touch is not None: root = App.get_running_app().root root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell']) self.dwell_started_by_touch = None Clock.unschedule(self.process_dwell) if self.global_ignore_momentum is False: # Set up momentum if not self.ignore_momentum: if self.do_translation_x is True and \ self.do_translation_y is True and \ abs(self.rotation-self.original_rotation) < 0.01: # check's that we haven't rotated, else the vectors for momentum will be off # tries to do a cheap check, if we haven't moved much, stop momentum from firing if touch.time_end-touch.time_update < 0.15: self.dx = touch.dx self.dy = touch.dy Clock.schedule_interval(self.inertial_translation, 0.02) return handled # ------------------------------------------------------------------------ ##############################################################################
def start(self): self.status = 'run' self.restart() Clock.unschedule(self.update) Clock.unschedule(self.new_column) Clock.schedule_interval(self.update, 1./60) Clock.schedule_interval(self.new_column, 1.3)
def on_touch_move(self, touch): if not touch.grab_current is self: return self._touch = False # skip on tablet mode if app.ui_mode[0] == 't': return super(Drawer, self).on_touch_move(touch) if not touch.ud.get('in_drag_area', None): return super(Drawer, self).on_touch_move(touch) ov = self.overlay_widget ov.x=min(self.hidden_widget.width, max(ov.x + touch.dx*2, 0)) #_anim = Animation(x=x, duration=1/2, t='in_out_quart') #_anim.cancel_all(ov) #_anim.start(ov) if abs(touch.x - touch.ox) < self.scroll_distance: return touch.ud['send_touch_down'] = False Clock.unschedule(self._change_touch_mode) self._touch = None self.state = 'opening' if touch.dx > 0 else 'closing' touch.ox = touch.x return
def on_touch_up(self, touch): if not touch.grab_current is self: return self._triigger_gc() touch.ungrab(self) touch.grab_current = None # skip on tablet mode get = touch.ud.get if app.ui_mode[0] == 't': return super(Drawer, self).on_touch_up(touch) self.old_x = [1, ] * 10 self.speed = sum(( (self.old_x[x + 1] - self.old_x[x]) for x in range(9))) / 9. if get('send_touch_down', None): # touch up called before moving Clock.unschedule(self._change_touch_mode) self._touch = None Clock.schedule_once( lambda dt: super(Drawer, self).on_touch_down(touch)) if get('in_drag_area', None): if abs(touch.x - touch.ox) < self.scroll_distance: anim_to = (0 if self.state[0] == 'c' else self.hidden_widget.width) Factory.Animation(x=anim_to, d=.1).start(self.overlay_widget) return touch.ud['in_drag_area'] = False if not get('send_touch_down', None): self.toggle_drawer() Clock.schedule_once(lambda dt: super(Drawer, self).on_touch_up(touch))
def sensor_update_values(self, *args): values = self.sensor_values[:2] if abs(values[0]) < 1.5 and abs(values[1]) < 1.5: if self.pacman.speed != (0, 0): Clock.unschedule(self.update_pacman) self.pacman.speed = (0, 0) else: speed = self.pacman.speed if abs(values[0]) > abs(values[1]): if values[0] < 0: self.pacman.speed = (0, 1) else: self.pacman.speed = (0, -1) else: if values[1] < 0: self.pacman.speed = (-1, 0) else: self.pacman.speed = (1, 0) if ((self.pacman.gridpos[0] + self.pacman.speed[0]) % 20, (self.pacman.gridpos[1] + self.pacman.speed[1]) % 11) in self.walls: if 1.5 < abs(values[0]) < abs(values[1]): if values[0] < 0: self.pacman.speed = (0, 1) else: self.pacman.speed = (0, -1) elif 1.5 < abs(values[1]) <= abs(values[0]): if values[1] < 0: self.pacman.speed = (-1, 0) else: self.pacman.speed = (1, 0) if speed == (0, 0) and self.pacman.speed != (0, 0): Clock.schedule_interval(self.update_pacman, self.pacman_time)
def _on_key_up(self, keyboard, keycode): speed = self.pacman.speed for k, s in ('w', (0, 1)), ('a', (-1, 0)), ('s', (0, -1)), ('d', (1, 0)): if keycode[1] == k and self.pacman.speed == s: self.pacman.speed = (0, 0) if speed != (0, 0) and self.pacman.speed == (0, 0): Clock.unschedule(self.update_pacman)
def set_new_bpm(self, *args): self.beat_value = self.sample_time_to_BPM(self.avg_sample_time) self.beat_counter_screen.setScreenValue(self.beat_value) if self.avg_sample_time > 0.0: Clock.unschedule(self.on_beat) self.on_beat()
def end_game(self): self.game_state = False Clock.unschedule(self.add_obstacle) #unscheduled incase game ends before event fires self.helicopter.touched_down = False #Need this line as the on_touch_up event isn't fired when the helicopter crashes self.score.new_high_score() self.app.game_over() Clock.schedule_once(self.app.start_popup, self.gameover_time)
def on_touch_move(self, touch): if touch.grab_current is not self: return False handled = super(DwellOnScatter, self).on_touch_move(touch) if handled: if self.ignore_dwell is not True: #if self.collide_point(touch.x, touch.y): # check dwell on myself, not the kids (todo: refine?) if self.dwell_started_by_touch != touch: self.dwell_started_counter = 0 if self.dwell_started_by_touch is not None: root = App.get_running_app().root root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell']) self.dwell_started_by_touch = None Clock.unschedule(self.process_dwell) else: # rather than base the calculation on the last touch frame, which means the user might be so slow, that a dwell follows them # base it on the original touch position, with the dwell_jitter_distance essentially mimicing a radius # around which a point can be within for the dwell to not be cancelled out diff = [abs(i-j) for i, j in zip(self.dwell_started_by_touch.opos,self.dwell_started_by_touch.pos)] #if abs(self.dwell_started_by_touch.dx) >= self.dwell_jitter_distance_ignore or abs(self.dwell_started_by_touch.dy) >= self.dwell_jitter_distance_ignore: if diff[0] >= self.dwell_jitter_distance_ignore or diff[1] >= self.dwell_jitter_distance_ignore: self.dwell_started_counter = 0 if self.dwell_started_by_touch is not None: root = App.get_running_app().root root.canvas.remove_group(self.dwell_started_by_touch.ud['dwell']) self.dwell_started_by_touch = None Clock.unschedule(self.process_dwell) else: pass # ignore little movements return handled
def SendCommand(self, oAction, oSetting, uRetVar, bNoLogOut=False): cBaseInterFace.SendCommand(self, oAction, oSetting, uRetVar, bNoLogOut) iTryCount = 0 iRet = 1 if oAction.dActionPars.get('commandname') == "send_string": uTmpVar = GetVar(uVarName='inputstring') uTmpVar2 = uTmpVar uTmpVar = uTmpVar.replace(" ", "%s") SetVar(uVarName='inputstring', oVarValue=uTmpVar) uRetVar = ReplaceVars(uRetVar) oSetting.uRetVar = uRetVar if uRetVar != "": oAction.uGlobalDestVar = uRetVar uParams = ReplaceVars(oAction.uParams) uParams = ReplaceVars(uParams, self.uInterFaceName + '/' + oSetting.uConfigName) while iTryCount < 2: iTryCount += 1 oSetting.Connect() if oSetting.bIsConnected: try: self.ShowDebug("Sending adb command: %s:%s" % (oAction.uCmd, uParams)) oMethod = getattr(oSetting.oDevice.oADB_Commands, oAction.uCmd) oResult = oMethod(uParams) uCmd, uRetVal = self.ParseResult(oAction, oResult, oSetting) self.ShowDebug(u'Parsed Resonse:' + uRetVal) if not uRetVar == u'': uRetVal = uRetVal.replace("\n", "") uRetVal = uRetVal.replace("\r", "") SetVar(uVarName=uRetVar, oVarValue=uRetVal) self.ShowDebug("Result:" + str(oResult)) break except Exception as e: self.ShowError(u'can\'t Send Message', oSetting.uConfigName, e) iRet = 1 else: oSetting.bIsConnected = False if oAction.dActionPars.get('commandname') == "send_string": SetVar(uVarName='inputstring', oVarValue=uTmpVar2) self.iLastRet = iRet if not bNoLogOut: if oSetting.aInterFaceIniSettings.iTimeToClose == 0: oSetting.Disconnect() elif oSetting.aInterFaceIniSettings.iTimeToClose != -1: Clock.unschedule(oSetting.FktDisconnect) Clock.schedule_once( oSetting.FktDisconnect, oSetting.aInterFaceIniSettings.iTimeToClose) return iRet
def on_release(self): Clock.unschedule(self.my_clock) self.do_action = "menu" return super(ReadingListComicImage, self).on_press()
def _trigger_select_name(self, name): part = partial(self.select_name, name) Clock.unschedule(part) Clock.schedule_once(part, 0)
def _trigger_save(self, name=None): part = partial(self.save, name=name) Clock.unschedule(part) Clock.schedule_once(part, 0)
def _trigger_redata(self, *args, **kwargs): part = partial(self.redata, *args, **kwargs) Clock.unschedule(part) Clock.schedule_once(part, 0)
def stop(self): Clock.unschedule(self.update) self.reader.processed_set = set()
def pause(self): Clock.unschedule(self.update)
def _clock_uninstall(self): if self._widgets or not self._clock_installed: return self._clock_installed = False Clock.unschedule(self._update)
def on_stop(self): if self.messropeWin.ids.qrcam.capture: print(self.messropeWin.ids.qrcam.capture) Clock.unschedule(self.messropeWin.ids.qrcam.clockEvent) self.messropeWin.ids.qrcam.capture.release() self.messropeWin.ids.qrcam.capture = None
def on_survivors(self, instance, value): if len(self.survivors)==0: Clock.unschedule(self.solo_attack) Clock.unschedule(self.shoot) self.invasion.end_game("You Win!")
def _mainloop(self): EventLoop.idle() while True: event = self._win.poll() if event is False: break if event is None: continue action, args = event[0], event[1:] if action == 'quit': EventLoop.quit = True self.close() break elif action in ('fingermotion', 'fingerdown', 'fingerup'): # for finger, pass the raw event to SDL motion event provider # XXX this is problematic. On OSX, it generates touches with 0, # 0 coordinates, at the same times as mouse. But it works. # We have a conflict of using either the mouse or the finger. # Right now, we have no mechanism that we could use to know # which is the preferred one for the application. if platform == "ios": SDL2MotionEventProvider.q.appendleft(event) pass elif action == 'mousemotion': x, y = args self.mouse_pos = x, self.system_size[1] - y self._mouse_x = x self._mouse_y = y # don't dispatch motion if no button are pressed if len(self._mouse_buttons_down) == 0: continue self._mouse_meta = self.modifiers self.dispatch('on_mouse_move', x, y, self.modifiers) elif action in ('mousebuttondown', 'mousebuttonup'): x, y, button = args btn = 'left' if button == 3: btn = 'right' elif button == 2: btn = 'middle' eventname = 'on_mouse_down' self._mouse_buttons_down.add(button) if action == 'mousebuttonup': eventname = 'on_mouse_up' self._mouse_buttons_down.remove(button) self._mouse_x = x self._mouse_y = y self.dispatch(eventname, x, y, btn, self.modifiers) elif action.startswith('mousewheel'): self._update_modifiers() x, y, button = args btn = 'scrolldown' if action.endswith('up'): btn = 'scrollup' elif action.endswith('right'): btn = 'scrollright' elif action.endswith('left'): btn = 'scrollleft' self._mouse_meta = self.modifiers self._mouse_btn = btn #times = x if y == 0 else y #times = min(abs(times), 100) #for k in range(times): self._mouse_down = True self.dispatch('on_mouse_down', self._mouse_x, self._mouse_y, btn, self.modifiers) self._mouse_down = False self.dispatch('on_mouse_up', self._mouse_x, self._mouse_y, btn, self.modifiers) elif action == 'dropfile': dropfile = args self.dispatch('on_dropfile', dropfile[0]) # video resize elif action == 'windowresized': if platform != "ios": self._size = args # don't use trigger here, we want to delay the resize event cb = self._do_resize Clock.unschedule(cb) Clock.schedule_once(cb, .1) elif action == 'windowresized': self.canvas.ask_update() elif action == 'windowrestored': self.canvas.ask_update() elif action == 'windowexposed': self.canvas.ask_update() elif action == 'windowminimized': if Config.getboolean('kivy', 'pause_on_minimize'): self.do_pause() elif action == 'joyaxismotion': stickid, axisid, value = args self.dispatch('on_joy_axis', stickid, axisid, value) elif action == 'joyhatmotion': stickid, hatid, value = args self.dispatch('on_joy_hat', stickid, hatid, value) elif action == 'joyballmotion': stickid, ballid, xrel, yrel = args self.dispatch('on_joy_ball', stickid, ballid, xrel, yrel) elif action == 'joybuttondown': stickid, buttonid = args self.dispatch('on_joy_button_down', stickid, buttonid) elif action == 'joybuttonup': stickid, buttonid = args self.dispatch('on_joy_button_up', stickid, buttonid) elif action in ('keydown', 'keyup'): mod, key, scancode, kstr = args key_swap = { SDLK_LEFT: 276, SDLK_RIGHT: 275, SDLK_UP: 273, SDLK_DOWN: 274, SDLK_HOME: 278, SDLK_END: 279, SDLK_PAGEDOWN: 281, SDLK_PAGEUP: 280, SDLK_SHIFTR: 303, SDLK_SHIFTL: 304, SDLK_SUPER: 309, SDLK_LCTRL: 305, SDLK_RCTRL: 306, SDLK_LALT: 308, SDLK_RALT: 307, SDLK_CAPS: 301, SDLK_INSERT: 277, SDLK_F1: 282, SDLK_F2: 283, SDLK_F3: 284, SDLK_F4: 285, SDLK_F5: 286, SDLK_F6: 287, SDLK_F7: 288, SDLK_F8: 289, SDLK_F9: 290, SDLK_F10: 291, SDLK_F11: 292, SDLK_F12: 293, SDLK_F13: 294, SDLK_F14: 295, SDLK_F15: 296, SDLK_KEYPADNUM: 300} if platform == 'ios': # XXX ios keyboard suck, when backspace is hit, the delete # keycode is sent. fix it. key_swap[127] = 8 # back try: key = key_swap[key] except KeyError: pass if action == 'keydown': self._update_modifiers(mod, key) else: self._update_modifiers(mod) # ignore the key, it # has been released # if mod in self._meta_keys: if (key not in self._modifiers and key not in self.command_keys.keys()): try: kstr = unichr(key) except ValueError: pass #if 'shift' in self._modifiers and key\ # not in self.command_keys.keys(): # return if action == 'keyup': self.dispatch('on_key_up', key, scancode) continue # don't dispatch more key if down event is accepted if self.dispatch('on_key_down', key, scancode, kstr, self.modifiers): continue self.dispatch('on_keyboard', key, scancode, kstr, self.modifiers) elif action == 'textinput': text = args[0] self.dispatch('on_textinput', text) # XXX on IOS, keydown/up don't send unicode anymore. # With latest sdl, the text is sent over textinput # Right now, redo keydown/up, but we need to seperate both call # too. (and adapt on_key_* API.) #self.dispatch() #self.dispatch('on_key_down', key, None, args[0], # self.modifiers) #self.dispatch('on_keyboard', None, None, args[0], # self.modifiers) #self.dispatch('on_key_up', key, None, args[0], # self.modifiers) # unhandled event ! else: Logger.trace('WindowSDL: Unhandled event %s' % str(event))
def _update_top(self, *args): sctr, top, scrl_v_width, x, y = args Clock.unschedule(partial(self._updt_top, sctr, top, scrl_v_width)) Clock.schedule_once(partial(self._updt_top, sctr, top, scrl_v_width), 0)
def on_leave(self): Clock.unschedule(self.timer)
def on_tab_width(self, *l): Clock.unschedule(self._update_tab_width) Clock.schedule_once(self._update_tab_width, 0)
def dismiss(self, *args, **kwargs): Clock.unschedule(self.clock_e) super(BlsSpeedPopup, self).dismiss(*args, **kwargs)
def on_noMoreDisplayd(self): try: Clock.unschedule(self.scheduler) except: print("no running scheduler for boatRender")
def _reposition_tabs(self, *l): Clock.unschedule(self._update_tabs) Clock.schedule_once(self._update_tabs, 0)
def die(dt): Clock.unschedule(tick) if self.parent: self.parent.remove_widget(self)
def nfc_disable(self): # print 'nfc_enable()' Clock.unschedule(self.on_new_intent)
def stop_recup(self): self.timer.cancel() print("Fin de la récupération") Clock.unschedule(self.timer) print(self.timer)
def on_pre_leave(self): Clock.unschedule(self.temp_schedule)
def stop_inertia(self): self.animating, self.xvel = False, 0 Clock.unschedule(self.animate)
def unschedule(): del active[:] Clock.unschedule(tick)
def on_hover(self, *a): if self.hover: Clock.schedule_once(self.show_label_info, 1) else: Clock.unschedule(self.show_label_info) infolabel.remove_info_on_mouse()
def stop(self): Clock.unschedule(self.update_values)
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 delholdclr(self, ins): Clock.unschedule(self.clearall)
def test_unschedule_event(self): from kivy.clock import Clock ev = Clock.schedule_once(callback) Clock.unschedule(ev) Clock.tick() self.assertEqual(counter, 0)
def update_strings(self): self.header_label.text = self.l.get_str("Welcome to SmartBench") self.next_button.text = self.l.get_str("Next") + "..." if self.update_welcome_header: Clock.unschedule(self.update_welcome_header)
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 anim_reset(self, allow_anim): '''Reset an animation if available. .. versionadded:: 1.0.8 :Parameters: `allow_anim`: bool Indicate whether the animation should restart playing or not. Usage:: # start/reset animation image.anim_reset(True) # or stop the animation image.anim_reset(False) You can change the animation speed whilst it is playing:: # Set to 20 FPS image.anim_delay = 1 / 20. ''' # stop animation Clock.unschedule(self._anim) if allow_anim and self._anim_available: Clock.schedule_interval(self._anim, self.anim_delay) self._anim()