當前位置: 首頁>>代碼示例>>Python>>正文


Python urwid.MainLoop方法代碼示例

本文整理匯總了Python中urwid.MainLoop方法的典型用法代碼示例。如果您正苦於以下問題:Python urwid.MainLoop方法的具體用法?Python urwid.MainLoop怎麽用?Python urwid.MainLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urwid的用法示例。


在下文中一共展示了urwid.MainLoop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def __init__(self, connection_name):
        try:
            self.connection_name = connection_name
            frame = self.getFrame()
            comp = self.getCommandProcessor()
            self.loop = urwid.MainLoop(urwid.AttrMap(frame, 'bg'),
                                        unhandled_input=comp.onInput,
                                        palette=themes['dark'])

            self.consoleMonitor = ScreepsConsoleMonitor(connection_name,
                                                        self.consoleWidget,
                                                        self.listWalker,
                                                        self.loop)

            comp.setDisplayWidgets(self.loop,
                                   frame,
                                   self.getConsole(),
                                   self.getConsoleListWalker(),
                                   self.getEdit(),
                                   self.consoleMonitor)
            self.loop.run()
        except KeyboardInterrupt:
            exit(0) 
開發者ID:screepers,項目名稱:screeps_console,代碼行數:25,代碼來源:interactive.py

示例2: setup_widgets

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def setup_widgets(self):
        self.intro_frame = urwid.LineBox(
            urwid.Filler(
                urwid.Text(('body_text', self.INTRO_MESSAGE.format("")), align=urwid.CENTER),
                valign=urwid.MIDDLE,
            )
        )

        self.frame = urwid.Frame(
            body=self.intro_frame,
            footer=urwid.Text(
                [self.FOOTER_START, ('heartbeat_inactive', self.HEARTBEAT_ICON)],
                align=urwid.CENTER
            )
        )

        self.loop = urwid.MainLoop(
            urwid.AttrMap(self.frame, 'body_text'),
            unhandled_input=show_or_exit,
            palette=PALETTE,
        )

        self.list_walker = urwid.SimpleListWalker(self.message_list)
        self.list_box = urwid.ListBox(self.list_walker)
        urwid.connect_signal(self.list_walker, "modified", self.item_focused) 
開發者ID:CaliDog,項目名稱:certstream-python,代碼行數:27,代碼來源:gui.py

示例3: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def __init__(self, client):
        self.client = client

        self.screen = urwid.raw_display.Screen()
        # self.screen = self.DummyScreen()

        self.frame = urwid.Frame(
            client.default_view,
            footer=urwid.Text("", align='center'),
        )

        self.client.frame = self.frame

        self.urwid_loop = urwid.MainLoop(
            self.frame,
            screen=self.screen,
            palette=palette,
            event_loop=self.FixedAsyncLoop(loop=client.loop),
            unhandled_input=client.handle_keypresses,
            pop_ups=True
        ) 
開發者ID:Fitblip,項目名稱:wsstat,代碼行數:23,代碼來源:gui.py

示例4: main

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def main():

    app = App()
    app.cfg = Config()

    app.hosts = load_test_data()

    page = UI_Credentials(parent=app)

    page.refresh()

    ui = page.render_page

    app.loop = urwid.MainLoop(ui,
                              palette,
                              unhandled_input=unknown_input)
    app.loop.run() 
開發者ID:pcuzner,項目名稱:ceph-ansible-copilot,代碼行數:19,代碼來源:test_ui.py

示例5: run

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def run():
    loop = MainLoop(wrapper, palette, handle_mouse=False,
                    unhandled_input=key_pressed)
    loop.run() 
開發者ID:leejaycoke,項目名稱:ec2-gazua,代碼行數:6,代碼來源:gazua.py

示例6: main

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def main(self) -> None:
        screen = Screen()
        screen.set_terminal_properties(colors=self.color_depth)
        self.loop = urwid.MainLoop(self.view,
                                   self.theme,
                                   screen=screen)
        self.update_pipe = self.loop.watch_pipe(self.draw_screen)

        # Register new ^C handler
        signal.signal(signal.SIGINT, self.exit_handler)

        try:
            # TODO: Enable resuming? (in which case, remove ^Z below)
            disabled_keys = {
                'susp': 'undefined',  # Disable ^Z - no suspending
                'stop': 'undefined',  # Disable ^S - enabling shortcut key use
                'quit': 'undefined',  # Disable ^\, ^4
            }
            old_signal_list = screen.tty_signal_keys(**disabled_keys)
            self.loop.run()

        except Exception:
            self.restore_stdout()
            screen.tty_signal_keys(*old_signal_list)
            raise

        finally:
            self.restore_stdout()
            screen.tty_signal_keys(*old_signal_list) 
開發者ID:zulip,項目名稱:zulip-terminal,代碼行數:31,代碼來源:core.py

示例7: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def __init__(self):
        self.prefs = bbjrc("load")
        self.client_pinned_threads = load_client_pins()
        self.usermap = {}
        self.match_data = {
            "query": "",
            "matches": [],
            "position": 0,
        }

        try:
            self.theme = themes[self.prefs["frame_theme"]].copy()
            if isinstance(self.prefs["custom_divider_char"], str):
                self.theme["divider"] = self.prefs["custom_divider_char"]
        except KeyError:
            exit("Selected theme does not exist. Please check "
                 "the `frame_theme` value in ~/.bbjrc")

        self.mode = None
        self.thread = None
        self.window_split = False
        self.last_index_pos = None
        self.last_alarm = None

        if self.prefs["use_custom_frame_title"]:
            self.frame_title = self.prefs["frame_title"]
        else:
            self.frame_title = network.instance_info["instance_name"]

        self.walker = urwid.SimpleFocusListWalker([])
        self.box = ActionBox(self.walker)
        self.body = urwid.AttrMap(
            urwid.LineBox(self.box, **self.frame_theme(self.frame_title)),
            "default"
        )
        self.loop = urwid.MainLoop(
            urwid.Frame(self.body),
            palette=colormap,
            handle_mouse=self.prefs["mouse_integration"]) 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:41,代碼來源:main.py

示例8: wipe_screen

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def wipe_screen(*_):
    """
    A crude hack to repaint the whole screen. I didnt immediately
    see anything to acheive this in the MainLoop methods so this
    will do, I suppose.
    """
    app.loop.stop()
    call("clear", shell=True)
    app.loop.start() 
開發者ID:bbj-dev,項目名稱:bbj,代碼行數:11,代碼來源:main.py

示例9: loop

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def loop(self, *args, **kwargs):
        kwargs.setdefault('unhandled_input', self.unhandled_input)
        loop = urwid.MainLoop(self.widget, self.palette, *args, **kwargs)
        return loop 
開發者ID:what-studio,項目名稱:profiling,代碼行數:6,代碼來源:viewer.py

示例10: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def __init__(self, update_mission=None, spin_switch=None):
    self.update_mission = update_mission or self.nothing
    self.spin_switch = spin_switch or self.nothing


    self.initAll()
    self.loop = urwid.MainLoop(self.columns, self.palette,
                                   unhandled_input=self._unhandled) 
開發者ID:AlexisTM,項目名稱:flyingros,代碼行數:10,代碼來源:urwid_app.py

示例11: run

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def run(self):
        loop = urwid.MainLoop(self._w, PALETTE, unhandled_input=self.unhandled_input, #pop_ups=True,
                event_loop=eventloop.PycopiaEventLoop())
        loop.run() 
開發者ID:kdart,項目名稱:pycopia,代碼行數:6,代碼來源:widgets.py

示例12: run

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def run(self):
        self.loop = urwid.MainLoop(self.top, widgets.PALETTE, unhandled_input=self.unhandled_input,
                event_loop=eventloop.PycopiaEventLoop())
        self.loop.run()
        self.loop = None 
開發者ID:kdart,項目名稱:pycopia,代碼行數:7,代碼來源:main.py

示例13: run

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def run(self):
        loop = urwid.MainLoop(self, PALETTE, unhandled_input=self.unhandled_input, pop_ups=True,
                event_loop=urwid.GLibEventLoop())
        loop.run() 
開發者ID:kdart,項目名稱:pycopia,代碼行數:6,代碼來源:widgets.py

示例14: run

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def run(self):
        self.loop = urwid.MainLoop(self.top, widgets.PALETTE,
                unhandled_input=self.unhandled_input, pop_ups=True, event_loop=eventloop.PycopiaEventLoop())
        self.loop.run()
        self.loop = None 
開發者ID:kdart,項目名稱:pycopia,代碼行數:7,代碼來源:main.py

示例15: __init__

# 需要導入模塊: import urwid [as 別名]
# 或者: from urwid import MainLoop [as 別名]
def __init__(self, config):
        self._loading = False
        self.config = config
        self.quick_switcher = None
        self.set_snooze_widget = None
        self.workspaces = list(config['workspaces'].items())
        self.store = Store(self.workspaces, self.config)
        Store.instance = self.store
        urwid.set_encoding('UTF-8')
        sidebar = LoadingSideBar()
        chatbox = LoadingChatBox('Everything is terrible!')
        palette = themes.get(config['theme'], themes['default'])

        custom_loop = SclackEventLoop(loop=loop)
        custom_loop.set_exception_handler(self._exception_handler)

        if len(self.workspaces) <= 1:
            self.workspaces_line = None
        else:
            self.workspaces_line = Workspaces(self.workspaces)

        self.columns = urwid.Columns([
            ('fixed', config['sidebar']['width'], urwid.AttrWrap(sidebar, 'sidebar')),
            urwid.AttrWrap(chatbox, 'chatbox')
        ])
        self._body = urwid.Frame(self.columns, header=self.workspaces_line)

        self.urwid_loop = urwid.MainLoop(
            self._body,
            palette=palette,
            event_loop=custom_loop,
            unhandled_input=self.unhandled_input
        )
        self.configure_screen(self.urwid_loop.screen)
        self.last_keypress = (0, None) 
開發者ID:haskellcamargo,項目名稱:sclack,代碼行數:37,代碼來源:app.py


注:本文中的urwid.MainLoop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。