Python urwid.MainLoop() Examples
The following are 30
code examples of urwid.MainLoop().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urwid
, or try the search function
.
Example #1
Source File: interactive.py From screeps_console with MIT License | 6 votes |
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)
Example #2
Source File: gui.py From certstream-python with MIT License | 6 votes |
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)
Example #3
Source File: gui.py From wsstat with MIT License | 6 votes |
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 )
Example #4
Source File: test_ui.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 6 votes |
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()
Example #5
Source File: copilot.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def setup(self): self.ssh = SSHConfig() if not self.ssh.configured: print("Unable to access/create ssh keys") sys.exit(4) self.file_timestamp = time.ctime() self.timestamp = int(time.time()) self.log = setup_logging() self.log.info("{} (v{}) starting at " "{}".format(os.path.basename(__file__), ceph_ansible_copilot.__version__, self.file_timestamp)) self._setup_dirs() self.plugin_mgr = PluginMgr(logger=self.log) self.log.info("{} plugin(s) " "loaded".format(len(self.plugin_mgr.plugins))) for plugin_name in self.plugin_mgr.plugins: mod = self.plugin_mgr.plugins[plugin_name].module self.log.info("- {}".format(mod.__file__[:-1])) # *.pyc -> *.py self.init_UI() self.loop = urwid.MainLoop(copilot.top, palette, unhandled_input=unknown_input)
Example #6
Source File: redial.py From redial with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.sessions = Config().load_from_file() top_node = UIParentNode(self.sessions, key_handler=self.on_key_press) self.walker = urwid.TreeWalker(top_node) self.listbox = UITreeListBox(self.walker) restore_ui_state(self.listbox, self.sessions) urwid.connect_signal(self.walker, "modified", lambda: on_focus_change(self.listbox)) header = urwid.Text("Redial") footer = init_footer(self.listbox) self.view = urwid.Frame( urwid.AttrWrap(self.listbox, 'body'), header=urwid.AttrWrap(header, 'head'), footer=footer) # Set screen to 256 color mode screen = urwid.raw_display.Screen() screen.set_terminal_properties(256) self.loop = urwid.MainLoop(self.view, palette, screen) # instance attributes self.command = None self.command_return_key = None self.log = None
Example #7
Source File: __main__.py From yTermPlayer with GNU General Public License v3.0 | 5 votes |
def main(): """Main script function.""" os.makedirs(PL_DIR, exist_ok=True) new_player=player_ui() loop = urwid.MainLoop(new_player.draw_ui(),palette,unhandled_input=new_player.handle_keys) loop.set_alarm_in(2, new_player.update_name) loop.run()
Example #8
Source File: terminal.py From terminal-leetcode with MIT License | 5 votes |
def run(self): self.loop = urwid.MainLoop(None, palette, unhandled_input=self.keystroke) self.show_loading('Log In', 12) self.t = Thread(target=self.run_retrieve_home) self.t.start() try: self.loop.run() except KeyboardInterrupt: self.logger.info('Keyboard interrupt') except Exception: self.logger.exception("Fatal error in main loop") finally: self.clear_thread() sys.exit()
Example #9
Source File: TerminusBrowser.py From TerminusBrowser with BSD 3-Clause "New" or "Revised" License | 5 votes |
def renderScreen(self): if __name__ == '__main__': # for testing purposes don't render outside file if self.mL == None: self.mL = urwid.MainLoop(self.body, self.palette, screen=self.screen, # event_loop=urwid.AsyncioEventLoop(loop=loop), unhandled_input=self.handleKey, pop_ups=True) self.mL.set_alarm_in(30, self.watcherUpdate) self.mL.run() else: self.mL.widget = self.body # self.mL.draw_screen()
Example #10
Source File: gui.py From TWchat with MIT License | 5 votes |
def createLoop(self): placeholder = urwid.SolidFill() urwid.set_encoding("UTF-8") self.loop = urwid.MainLoop(placeholder,self.palette,unhandled_input=exit_on_alt_q) self.loop.screen.set_terminal_properties(colors=256) self.loop.widget = urwid.AttrMap(placeholder, 'bg') self.loop.widget.original_widget = urwid.Filler(self.createLayout()) self.loop.run()
Example #11
Source File: manager_ui.py From sisyphus with Mozilla Public License 2.0 | 5 votes |
def setup(self): self.logs = [] self.log_handler = None self.setup_view() self.loop = urwid.MainLoop(self.main_view, self.palette, unhandled_input=self.unhandled_input) self._external_event_pipe = self.loop.watch_pipe(self.external_event_handler)
Example #12
Source File: view.py From binch with MIT License | 5 votes |
def main(self): self.loop = urwid.MainLoop(self.view, self.palette, handle_mouse=False, unhandled_input=self.unhandled_input) self.loop.set_alarm_in(0.03, self.update_status) try: self.loop.run() except: self.loop.stop() print(traceback.format_exc())
Example #13
Source File: app.py From clay with GNU General Public License v3.0 | 5 votes |
def set_loop(self, loop): """ Assign a MainLoop to this app. """ self.loop = loop
Example #14
Source File: cli.py From EvilOSX with GNU General Public License v3.0 | 5 votes |
def start(self): main_loop = urwid.MainLoop(self._frame, self._PALETTE, handle_mouse=True) self._set_main_loop(main_loop) self._output_view.set_main_loop(main_loop) self._command_input.set_main_loop(main_loop) main_loop.run()
Example #15
Source File: app.py From toot with GNU General Public License v3.0 | 5 votes |
def create(cls, app, user): """Factory method, sets up TUI and an event loop.""" tui = cls(app, user) loop = urwid.MainLoop( tui, palette=PALETTE, event_loop=urwid.AsyncioEventLoop(), unhandled_input=tui.unhandled_input, ) tui.loop = loop return tui
Example #16
Source File: app.py From usolitaire with MIT License | 5 votes |
def main(): import argparse parser = argparse.ArgumentParser(description=__doc__) parser.parse_args() app = GameApp() loop = urwid.MainLoop( urwid.Filler(app.main_layout, valign='top'), PALETTE, unhandled_input=exit_on_q, ) loop.run()
Example #17
Source File: browse.py From zstack-utility with Apache License 2.0 | 5 votes |
def main(self): """Run the program.""" self.loop = urwid.MainLoop(self.view, self.palette, unhandled_input=self.unhandled_input) self.loop.run() # on exit, write the flagged filenames to the console names = [escape_filename_sh(x) for x in get_flagged_names()] print " ".join(names)
Example #18
Source File: setting.py From zstack-utility with Apache License 2.0 | 5 votes |
def main(self): self.loop = urwid.MainLoop(self.view, self.palette, unhandled_input=self._unhandled_input) self.loop.run()
Example #19
Source File: test.py From zstack-utility with Apache License 2.0 | 5 votes |
def main(self): lst = [] walker = urwid.SimpleListWalker(lst) self.frame = urwid.ListBox(walker) for i in range(1000): txt = urwid.Text('%s' % i) lst.append(txt) walker._modified() self.frame.set_focus_valign('top') self.loop = urwid.MainLoop(self.frame, self.palette, unhandled_input=self.unhandled_input) self.loop.run()
Example #20
Source File: ui.py From tildemush with GNU General Public License v3.0 | 5 votes |
def __init__(self, loop): base = urwid.SolidFill("") self.loop = urwid.MainLoop( base, event_loop=urwid.AsyncioEventLoop(loop=loop), palette=palettes) self.base = base
Example #21
Source File: core.py From zulip-terminal with Apache License 2.0 | 5 votes |
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)
Example #22
Source File: main.py From bbj with MIT License | 5 votes |
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"])
Example #23
Source File: main.py From bbj with MIT License | 5 votes |
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()
Example #24
Source File: viewer.py From profiling with BSD 3-Clause "New" or "Revised" License | 5 votes |
def loop(self, *args, **kwargs): kwargs.setdefault('unhandled_input', self.unhandled_input) loop = urwid.MainLoop(self.widget, self.palette, *args, **kwargs) return loop
Example #25
Source File: urwid_app.py From flyingros with GNU General Public License v3.0 | 5 votes |
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)
Example #26
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def run(self): loop = urwid.MainLoop(self._w, PALETTE, unhandled_input=self.unhandled_input, #pop_ups=True, event_loop=eventloop.PycopiaEventLoop()) loop.run()
Example #27
Source File: main.py From pycopia with Apache License 2.0 | 5 votes |
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
Example #28
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def run(self): loop = urwid.MainLoop(self, PALETTE, unhandled_input=self.unhandled_input, pop_ups=True, event_loop=urwid.GLibEventLoop()) loop.run()
Example #29
Source File: main.py From pycopia with Apache License 2.0 | 5 votes |
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
Example #30
Source File: app.py From sclack with GNU General Public License v3.0 | 5 votes |
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)