def prev(self, *args):
self.root.sm.transition = SlideTransition(direction="right")
self.root.sm.current = 'TutorialNavigate'
Clock.unschedule(self.nextFrame)
python类unschedule()的实例源码
def nextScreen(self, *args):
self.root.sm.transition = SlideTransition(direction="left")
self.root.sm.current = 'MainMenuScreen'
Clock.unschedule(self.nextFrame)
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 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 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 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 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)
def exit(self, dt):
Clock.unschedule(self.exit)
anim = Animation(y = metrics.dp(-50), t = 'in_out_expo')
anim.start(self)
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)