当前位置: 首页>>代码示例>>Python>>正文


Python urwid.ExitMainLoop方法代码示例

本文整理汇总了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 
开发者ID:TimeTraveller-San,项目名称:yTermPlayer,代码行数:23,代码来源:ui.py

示例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() 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:19,代码来源:demo.py

示例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) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:27,代码来源:test_event_loops.py

示例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)') 
开发者ID:insanum,项目名称:sncli,代码行数:14,代码来源:sncli.py

示例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') 
开发者ID:ids1024,项目名称:wikicurses,代码行数:35,代码来源:main.py

示例6: key_pressed

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def key_pressed(key):
    if key == 'esc':
        raise urwid.ExitMainLoop() 
开发者ID:leejaycoke,项目名称:ec2-gazua,代码行数:5,代码来源:gazua.py

示例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 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:32,代码来源:events.py

示例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() 
开发者ID:conjure-up,项目名称:conjure-up,代码行数:13,代码来源:base.py

示例9: exit

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def exit(self, comp):
        raise urwid.ExitMainLoop() 
开发者ID:screepers,项目名称:screeps_console,代码行数:4,代码来源:command.py

示例10: unhandled_input

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def unhandled_input(self, key):
        if key in ('q', 'Q'):
            raise urwid.ExitMainLoop() 
开发者ID:what-studio,项目名称:profiling,代码行数:5,代码来源:viewer.py

示例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 
开发者ID:TomasTomecek,项目名称:sen,代码行数:13,代码来源:ui.py

示例12: quit

# 需要导入模块: import urwid [as 别名]
# 或者: from urwid import ExitMainLoop [as 别名]
def quit(self):
    """Quit the program."""
    raise urwid.ExitMainLoop() 
开发者ID:AlexisTM,项目名称:flyingros,代码行数:5,代码来源:urwid_app.py

示例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() 
开发者ID:AlexisTM,项目名称:flyingros,代码行数:10,代码来源:console_task_urwid_functions.py

示例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) 
开发者ID:kdart,项目名称:pycopia,代码行数:6,代码来源:widgets.py

示例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() 
开发者ID:kdart,项目名称:pycopia,代码行数:13,代码来源:main.py


注:本文中的urwid.ExitMainLoop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。