本文整理汇总了Python中urwid.ExitMainLoop方法的典型用法代码示例。如果您正苦于以下问题:Python urwid.ExitMainLoop方法的具体用法?Python urwid.ExitMainLoop怎么用?Python urwid.ExitMainLoop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid
的用法示例。
在下文中一共展示了urwid.ExitMainLoop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_keys
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def handle_keys(self,key):
if(key=='q'):
raise urwid.ExitMainLoop()
key_dict={
'n':self.player_object.play_next,
'p':self.player_object.play_prev,
'h':self.player_object.play_first,
'e':self.player_object.play_last,
' ':self.toggle_playing,
's':self.save_list,
'1': self.change_play_mode_to_repeat_one,
'2': self.change_play_mode_to_repeat_list,
'3': self.change_play_mode_to_repeat_off,
'r': self.change_play_mode_to_random,
'u': self.volume_up,
'd': self.volume_down,
}
try:
key_dict[key]()
except:
pass
示例2: keypress
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def keypress(self, size, key):
key = super(SetupListBox, self).keypress(size, key)
if key == 'enter':
if self.focus_position > 2 and len(self.body[self.focus_position].edit_text) == 0:
device_name = self.body[2].edit_text
device_listens = []
for index, item in enumerate(self.body):
if index > 2:
device_listens.append(item.edit_text)
start_anymesh(device_name, device_listens)
load_msg_frame()
else:
self.body.insert(self.focus_position + 1, urwid.Edit("Enter a keyword to listen to: "))
self.focus_position += 1
elif key == 'esc':
raise urwid.ExitMainLoop()
示例3: test_run
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def test_run(self):
evl = self.evl
out = []
rd, wr = os.pipe()
self.assertEqual(os.write(wr, "data".encode('ascii')), 4)
def step2():
out.append(os.read(rd, 2).decode('ascii'))
def say_hello():
out.append("hello")
def say_waiting():
out.append("waiting")
def exit_clean():
out.append("clean exit")
raise urwid.ExitMainLoop
def exit_error():
1/0
handle = evl.watch_file(rd, step2)
handle = evl.alarm(0.01, exit_clean)
handle = evl.alarm(0.005, say_hello)
self.assertEqual(evl.enter_idle(say_waiting), 1)
evl.run()
self.assertIn("da", out)
self.assertIn("ta", out)
self.assertIn("hello", out)
self.assertIn("clean exit", out)
示例4: gui_stop
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def gui_stop(self):
# don't exit if there are any notes not yet saved to the disk
# NOTE: this was originally causing hangs on exit with urllib2
# should not be a problem now since using the requests library
# ref https://github.com/insanum/sncli/issues/18#issuecomment-105517773
if self.ndb.verify_all_saved():
# clear the screen and exit the urwid run loop
self.gui_clear()
raise urwid.ExitMainLoop()
else:
self.log(u'WARNING: Not all notes saved to disk (wait for sync worker)')
示例5: processCmd
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def processCmd(cmd, *args):
global current
if cmd in ('q', 'quit'):
raise urwid.ExitMainLoop
elif cmd == 'bmark':
wiki.bmarks.add(page.title)
ex.notify("Bookmark Added")
elif cmd in overlaymap:
openOverlay(overlaymap[cmd]())
elif cmd == 'open':
if args:
openPage(' '.join(args))
else:
openOverlay(SearchBox())
elif cmd == 'clearcache':
wiki.clear_cache()
elif cmd == 'edit':
edit(page.title)
elif cmd == 'help':
executeCommand(['man', 'wikicurses'])
elif cmd == 'back':
if current > 0:
current -= 1
openPage(history[current], browsinghistory=True)
elif cmd == 'forward':
if current < len(history)-1:
current += 1
openPage(history[current], browsinghistory=True)
elif cmd == 'random':
openPage(wiki.random())
elif cmd:
ex.notify(cmd + ': Unknown Command')
示例6: key_pressed
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def key_pressed(key):
if key == 'esc':
raise urwid.ExitMainLoop()
示例7: handle_exception
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def handle_exception(loop, context):
exc = context.get('exception')
if exc is None or isinstance(exc, CancelledError):
return # not an error, cleanup message
if isinstance(exc, ExitMainLoop):
Shutdown.set() # use previously stored exit code
return
if Error.is_set():
return # already reporting an error
Error.set()
exc_info = (type(exc), exc, exc.__traceback__)
if any(pred(exc) for pred in NOTRACK_EXCEPTIONS):
app.log.debug('Would not track exception: {}'.format(exc))
if not (app.no_report or any(pred(exc) for pred in NOTRACK_EXCEPTIONS)):
track_exception(str(exc))
utils.sentry_report(exc_info=exc_info)
msg = 'Unhandled exception'
if 'future' in context:
msg += ' in {}'.format(context['future'])
app.log.exception(msg, exc_info=exc)
if app.headless:
msg = str(exc)
utils.error(msg)
Shutdown.set(1)
else:
app.exit_code = 1 # store exit code for later
app.ui.show_exception_message(exc) # eventually raises ExitMainLoop
示例8: show
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def show(self):
def _stop(key):
if key in ['q', 'Q']:
raise ExitMainLoop()
app.no_track = True
app.no_report = True
app.ui = ConjureUI()
EventLoop.build_loop(app.ui, STYLES, unhandled_input=_stop)
super().show()
EventLoop.run()
示例9: exit
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def exit(self, comp):
raise urwid.ExitMainLoop()
示例10: unhandled_input
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def unhandled_input(self, key):
if key in ('q', 'Q'):
raise urwid.ExitMainLoop()
示例11: quit
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def quit(self):
"""
This could be called from another thread, so let's do this via alarm
"""
def q(*args):
raise urwid.ExitMainLoop()
self.worker.shutdown(wait=False)
self.ui_worker.shutdown(wait=False)
self.loop.set_alarm_in(0, q)
# FIXME: move these to separate mixin
示例12: quit
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def quit(self):
"""Quit the program."""
raise urwid.ExitMainLoop()
示例13: keyboard_handler
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def keyboard_handler(key):
global taskListbox, tasksWidget
if key in ('a', 'A'):
pass
elif key == 'enter':
pass
elif key in ('q', 'Q', 'ESC'):
raise urwid.ExitMainLoop()
示例14: unhandled_input
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def unhandled_input(self, k):
if k == "esc":
raise urwid.ExitMainLoop()
DEBUG("unhandled key:", k)
示例15: _popform
# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def _popform(self, form):
if form is not None:
urwid.disconnect_signal(form, 'pushform', self._pushform)
urwid.disconnect_signal(form, 'popform', self._popform)
urwid.disconnect_signal(form, 'message', self._message)
if self._formtrail:
self.form = self._formtrail.pop()
#self.form.invalidate()
self.top.body = self.form
else:
raise urwid.ExitMainLoop()