當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。