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'
python类unschedule()的实例源码
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 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 nextScreen(self, *args):
self.root.sm.transition = SlideTransition(direction="left")
self.root.sm.current = self.root.sm.next()
Clock.unschedule(self.nextFrame)