本文整理汇总了Python中kivy.properties.Clock.schedule_once方法的典型用法代码示例。如果您正苦于以下问题:Python Clock.schedule_once方法的具体用法?Python Clock.schedule_once怎么用?Python Clock.schedule_once使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.properties.Clock
的用法示例。
在下文中一共展示了Clock.schedule_once方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_enter
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_enter(self):
global ENTRY_PLAYER
if ENTRY_PLAYER == 0:
MAIN_SOUND.stop()
ENTRY_PLAYER = 1
self.ids.grid.top = 760
self.ids.grid.right = 1350
for i in range(NUMBER_OF_BUTTONS):
for j in range(NUMBER_OF_BUTTONS):
button = Button(text="")
button.size_hint = (100, 100)
button.coords = (i, j)
button.bind(on_press=self.button_pressed)
for ship in SHIPS_OF_PLAYER:
if ship[0] == (i, j):
button.background_color = ship[1]
button.name = str(ship[2])
self.ids.grid.add_widget(button)
self.manager.current = 'board2'
self.popup.open()
Clock.schedule_once(self.callback, 1.5)
示例2: on_close_tab
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_close_tab(self, instance, *args):
'''Event handler to close icon
:param instance: tab instance
'''
d = get_designer()
if d.popup:
return False
self.switch_to(instance)
if instance.has_modification:
# show a dialog to ask if can close
confirm_dlg = ConfirmationDialog(
'All unsaved changes will be lost.\n'
'Do you want to continue?')
popup = Popup(
title='New',
content=confirm_dlg,
size_hint=(None, None),
size=('200pt', '150pt'),
auto_dismiss=False)
def close_tab(*args):
d.close_popup()
self._perform_close_tab(instance)
confirm_dlg.bind(
on_ok=close_tab,
on_cancel=d.close_popup)
popup.open()
d.popup = popup
else:
Clock.schedule_once(partial(self._perform_close_tab, instance))
示例3: callback1
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def callback1(self, dt):
if dt >= 0.9:
self.manager.get_screen('board1').popup.dismiss()
self.manager.current = 'board2'
else:
self.manager.get_screen('board1').popup.open()
Clock.schedule_once(self.callback1, 1)
示例4: on_text
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_text(self, *args):
"""updates the tab width when it has a new title
"""
def update_width(*args):
self.width = min(self.texture_size[0] + 40, 200)
Clock.schedule_once(update_width)
示例5: on_pre_enter
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_pre_enter(self):
for child in self.ids.grid.children:
child.background_color = [1, 1, 1, 1]
def my_callback(dt):
view.dismiss()
view = ModalView(size=(100, 100))
view.background = 'img.jpg'
view.open()
Clock.schedule_once(my_callback, 5)
示例6: button_pressed
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def button_pressed(self, button):
if button.text == 'YES':
self.manager.current = 'main'
self.popup.dismiss()
else:
global CURRENT_PLAYER, AMOUNT, CURRENT1, SOME_LIST1
row, column = button.coords
status_index = row * 10 + column
already_played = self.status[status_index]
if not already_played and CURRENT_PLAYER == 1:
self.status[status_index] = CURRENT_PLAYER
for ship in SHIPS_OF_COMP:
if ship[0] == (row, column):
CURRENT1 += 1
SOME_LIST1.append((row, column))
button.background_color = ship[1]
#button.text = str(ship[2])
self.sound.stop()
self.sound = SoundLoader.load('bomb2.wav')
self.sound.play()
if CURRENT1 == ship[2]:
for ship in SOME_LIST1:
x, y = ship
s = [1, 0, -1]
t = [1, 0, -1]
for xx in s:
for yy in t:
for child in self.ids.grid.children:
if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST1:
child.text = 'X'
child.background_color = [1, 0, 0, 1]
SOME_LIST1 = []
CURRENT1 = 0
AMOUNT += 1
if AMOUNT == 4 + 3 * 2 + 2 * 3 + 4:
Winner.play()
winner.children[0].text = 'You WIN!!!!!'
winner.bind(on_dismiss = self.somefunc)
winner.open()
break
if button.background_color == [1, 1, 1, 1]:
button.text = 'X'
self.sound.stop()
self.sound = SoundLoader.load('Not_ship.wav')
self.sound.play()
button.background_color = [1, 0, 0, 1]
Clock.schedule_once(self.callback, 1)
CURRENT_PLAYER *= -1
示例7: on_close_tab
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_close_tab(self, instance, *args):
"""Event handler to close icon
:param instance: tab instance
"""
self.switch_to(instance)
if instance.has_modification:
# show a dialog to ask if can close
confirm_dlg = ConfirmationDialog("All unsaved changes will be lost.\n" "Do you want to continue?")
self._popup = Popup(
title="New", content=confirm_dlg, size_hint=(None, None), size=("200pt", "150pt"), auto_dismiss=False
)
confirm_dlg.bind(on_ok=partial(self._perform_close_tab, instance), on_cancel=self._popup.dismiss)
self._popup.open()
else:
Clock.schedule_once(partial(self._perform_close_tab, instance))
示例8: pull
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def pull(*args):
'''Do a pull in a separated thread
'''
try:
remote_repo.pull(progress=progress)
def set_progress_done(*args):
progress.label.text = 'Completed!'
Clock.schedule_once(set_progress_done, 1)
progress.stop()
show_message('Git remote pull completed!', 5)
except GitCommandError as e:
progress.label.text = 'Failed to pull!\n' + str(e)
get_designer().close_popup()
示例9: push
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def push(*args):
'''Do a push in a separated thread
'''
try:
remote_repo.push(self.repo.active_branch.name,
progress=progress)
def set_progress_done(*args):
progress.label.text = 'Completed!'
Clock.schedule_once(set_progress_done, 1)
progress.stop()
show_message('Git remote push completed!', 5)
except GitCommandError as e:
progress.label.text = 'Failed to push!\n' + str(e)
self._popup.dismiss()
示例10: _send_command_result
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def _send_command_result(self, request, response):
# Parses API-call response
try:
if response['status'] not in self._completed:
# Executing in progress
self._cmd_id = response['id']
if self._wait_completion:
Clock.schedule_once(self._get_status, 1)
else:
# Command "completed"
if response['status'] == self._completed[0]:
self.last_accepted_command = response['code_dsp']
self._progress_complete(
'Command "%s" is %s' %
(response['code_dsp'], response['status_dsp']))
except Exception as e:
XError(text=str(e)[:256])
示例11: _reset_screensaver
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def _reset_screensaver(self, *args, **kwargs):
# Change screen only of key is not left/right (what we use to navigate screens)
if self.screen_manager.current == self.saver_screen and (
'key' not in kwargs or kwargs['key'] not in ['right', 'left']):
while self.screen_manager.current != self.default_screen:
self._key_left()
if self.saver_scheduler:
self.saver_scheduler.cancel()
if self._screensaver_enabled():
self.saver_scheduler = Clock.schedule_once(self._start_screensaver,
float(self.config.get('main', 'screensaver_timeout')))
示例12: my_callback
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def my_callback(self, dt):
self.current += dt
if self.current > 5:
global CURRENT_PLAYER, LIST_OF_TARGETS1, LIST_OF_TARGETS, CURRENT, SOME_LIST, AMOUNT1
grid = self.manager.get_screen('board1').ids.grid
rand = random.randint(0, len(LIST_OF_TARGETS) - 1)
TARGETS = LIST_OF_TARGETS
if len(LIST_OF_TARGETS1):
rand = random.randint(0, len(LIST_OF_TARGETS1) - 1)
TARGETS = LIST_OF_TARGETS1
for child in grid.children:
if child.coords == TARGETS[rand]:
if child.background_color == [1, 1, 1, 1]:
child.text = 'X'
child.background_color = [1, 0, 0, 1]
self.popup1.dismiss()
Clock.unschedule(self.my_callback)
CURRENT_PLAYER *= -1
self.sound.stop()
self.sound = SoundLoader.load('Not_ship.wav')
self.sound.play()
Clock.schedule_once(self.callback1, 0.7)
TARGETS.remove(child.coords)
else:
x, y = child.coords
CURRENT += 1
AMOUNT1 += 1
SOME_LIST.append((x, y))
if (x + 1, y + 1) in TARGETS:
TARGETS.remove((x + 1, y + 1))
if (x - 1, y - 1) in TARGETS:
TARGETS.remove((x - 1, y - 1))
if (x + 1, y - 1) in TARGETS:
TARGETS.remove((x + 1, y - 1))
if (x - 1, y + 1) in TARGETS:
TARGETS.remove((x - 1, y + 1))
if (x + 1, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x + 1, y + 1))
if (x - 1, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x - 1, y - 1))
if (x + 1, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x + 1, y - 1))
if (x - 1, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x - 1, y + 1))
if (x + 1, y) not in LIST_OF_TARGETS1 and (x + 1, y) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x + 1, y))
LIST_OF_TARGETS.remove((x + 1, y))
if (x - 1, y) not in LIST_OF_TARGETS1 and (x - 1, y) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x - 1, y))
LIST_OF_TARGETS.remove((x - 1, y))
if (x, y - 1) not in LIST_OF_TARGETS1 and (x, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x, y - 1))
LIST_OF_TARGETS.remove((x, y - 1))
if (x, y + 1) not in LIST_OF_TARGETS1 and (x, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x, y + 1))
LIST_OF_TARGETS.remove((x, y + 1))
child.background_color = [0, 1, 0, 1]
if AMOUNT1 == 4 + 3 * 2 + 2 * 3 + 4:
self.popup1.dismiss()
Clock.unschedule(self.my_callback)
Lose.play()
winner.children[0].text = 'You Lost!!!!!'
winner.bind(on_dismiss = self.somefunc)
winner.open()
return
TARGETS.remove((x, y))
if CURRENT == int(child.name):
LIST_OF_TARGETS1[:] = []
for ship in SOME_LIST:
x, y = ship
s = [1, 0, -1]
t = [1, 0, -1]
for xx in s:
for yy in t:
for child in grid.children:
if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST:
child.text = 'X'
child.background_color = [1, 0, 0, 1]
SOME_LIST = []
CURRENT = 0
self.current = 0
self.sound.stop()
self.sound = SoundLoader.load('bomb2.wav')
self.sound.play()
return
child = self.popup1.children[0]
if child.text[-1:-4:-1] == '...':
child.text = child.text[:-3]
else:
child.text += '.'
示例13: on_webdebugger
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def on_webdebugger(self, *args):
'''when running from webdebugger'''
self.dispatch('on_module', mod='webdebugger', data=[])
Clock.schedule_once(partial(webbrowser.open,
'http://localhost:5000/'), 5)
示例14: my_callback
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def my_callback(self, dt):
self.current += dt
if self.current > 2:
global CURRENT_PLAYER, LIST_OF_TARGETS1, LIST_OF_TARGETS, CURRENT, SOME_LIST, AMOUNT1, finish
grid = self.manager.get_screen('board1').ids.grid
rand = random.randint(0, len(LIST_OF_TARGETS) - 1)
TARGETS = LIST_OF_TARGETS
if len(LIST_OF_TARGETS1):
rand = random.randint(0, len(LIST_OF_TARGETS1) - 1)
TARGETS = LIST_OF_TARGETS1
for child in grid.children:
if child.coords == TARGETS[rand]:
if child.background_color == [1, 1, 1, 1]:
child.text = 'X'
child.background_color = [1, 0, 0, 1]
self.popup1.dismiss()
Clock.unschedule(self.my_callback)
CURRENT_PLAYER *= -1
self.sound.stop()
self.sound = SoundLoader.load('files/Not_ship.wav')
self.sound.play()
Clock.schedule_once(self.callback1, 0.7)
TARGETS.remove(child.coords)
else:
x, y = child.coords
CURRENT += 1
AMOUNT1 += 1
SOME_LIST.append((x, y))
if (x + 1, y + 1) in TARGETS:
TARGETS.remove((x + 1, y + 1))
if (x - 1, y - 1) in TARGETS:
TARGETS.remove((x - 1, y - 1))
if (x + 1, y - 1) in TARGETS:
TARGETS.remove((x + 1, y - 1))
if (x - 1, y + 1) in TARGETS:
TARGETS.remove((x - 1, y + 1))
if (x + 1, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x + 1, y + 1))
if (x - 1, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x - 1, y - 1))
if (x + 1, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x + 1, y - 1))
if (x - 1, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS.remove((x - 1, y + 1))
if (x + 1, y) not in LIST_OF_TARGETS1 and (x + 1, y) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x + 1, y))
LIST_OF_TARGETS.remove((x + 1, y))
if (x - 1, y) not in LIST_OF_TARGETS1 and (x - 1, y) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x - 1, y))
LIST_OF_TARGETS.remove((x - 1, y))
if (x, y - 1) not in LIST_OF_TARGETS1 and (x, y - 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x, y - 1))
LIST_OF_TARGETS.remove((x, y - 1))
if (x, y + 1) not in LIST_OF_TARGETS1 and (x, y + 1) in LIST_OF_TARGETS:
LIST_OF_TARGETS1.append((x, y + 1))
LIST_OF_TARGETS.remove((x, y + 1))
child.background_color = [0, 1, 0, 1]
AMOUNT1 = 4 + 3 * 2 + 2 * 3 + 4
if AMOUNT1 == 4 + 3 * 2 + 2 * 3 + 4:
self.popup1.dismiss()
Clock.unschedule(self.my_callback)
finish = SoundLoader.load('files/proval.mp3')
finish.play()
winner = ModalView(size_hint=(0.75, 0.5))
winner.background = 'files/You_Lost.png'
# victory_label = Label(text='You Lost!!!!!', font_size=50)
# winner.add_widget(victory_label)
winner.bind(on_dismiss=self.somefunc)
winner.open()
return
TARGETS.remove((x, y))
if CURRENT == int(child.name):
LIST_OF_TARGETS1[:] = []
if self.sound != '':
self.sound.stop()
self.sound = SoundLoader.load('files/boom.mp3')
self.sound.play()
for ship in SOME_LIST:
x, y = ship
s = [1, 0, -1]
t = [1, 0, -1]
for xx in s:
for yy in t:
for child in grid.children:
if child.coords == (x + xx, y + yy) and (x + xx, y + yy) not in SOME_LIST:
child.text = 'X'
child.background_color = [1, 0, 0, 1]
SOME_LIST = []
CURRENT = 0
else:
if self.sound != '':
self.sound.stop()
self.sound = SoundLoader.load('files/bomb2.wav')
#.........这里部分代码省略.........
示例15: resume_watching
# 需要导入模块: from kivy.properties import Clock [as 别名]
# 或者: from kivy.properties.Clock import schedule_once [as 别名]
def resume_watching(self, delay=1):
'''Resume the watcher
:param delay: seconds to start the watching
'''
Clock.schedule_once(self._resume_watching, delay)