Python urwid.Overlay() Examples
The following are 30
code examples of urwid.Overlay().
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: views.py From zulip-terminal with Apache License 2.0 | 6 votes |
def __init__(self, controller: Any, question: Any, success_callback: Callable[[], bool]): self.controller = controller self.success_callback = success_callback yes = urwid.Button('Yes', self.exit_popup_yes) no = urwid.Button('No', self.exit_popup_no) yes._w = urwid.AttrMap(urwid.SelectableIcon( 'Yes', 4), None, 'selected') no._w = urwid.AttrMap(urwid.SelectableIcon( 'No', 4), None, 'selected') display_widget = urwid.GridFlow([yes, no], 3, 5, 1, 'center') wrapped_widget = urwid.WidgetWrap(display_widget) prompt = urwid.LineBox( urwid.ListBox( urwid.SimpleFocusListWalker( [question, urwid.Divider(), wrapped_widget] ))) urwid.Overlay.__init__(self, prompt, self.controller.view, align="left", valign="top", width=self.controller.view.LEFT_WIDTH + 1, height=8)
Example #2
Source File: screen.py From alertR with GNU Affero General Public License v3.0 | 6 votes |
def _showSearchView(self): self.searchView = SearchViewUrwid(self._callbackSearchFieldChange) # show search view as an overlay overlayView = urwid.Overlay(self.searchView.get(), self.mainFrame, align="center", width=("relative", 80), min_width=80, valign="middle", height=("relative", 5), min_height=5) self.mainLoop.widget = overlayView self.inSearchView = True # internal function that shows the sensor urwid objects given # by a page index
Example #3
Source File: scroll_test.py From stig with GNU General Public License v3.0 | 6 votes |
def test_shards_bug(self): scrl = Scrollable( urwid.Pile([urwid.Columns([urwid.Text("text")] * 3)] * 3) ) sb = ScrollBar(scrl, thumb_char='#', trough_char='|', width=3) area = urwid.Overlay(urwid.SolidFill("O"), sb, "center", 4, "middle", 5) self.check(area, (10, 5), cursor_pos=(), text=( 'tetOOOO###', 'xttOOOO###', 'tetOOOO###', 'xttOOOO###', 'tetOOOO|||', )) # https://github.com/urwid/urwid/issues/226#issuecomment-437176837
Example #4
Source File: main.py From bbj with MIT License | 6 votes |
def quote_view_action(self, button, message): """ Callback function to view a quote from the message object menu. """ widget = OptionsMenu( ActionBox(urwid.SimpleFocusListWalker(self.make_message_body(message))), **self.frame_theme(">>%d" % message["post_id"]) ) self.loop.widget = urwid.Overlay( widget, self.loop.widget, align=("relative", 50), valign=("relative", 50), width=("relative", 98), height=("relative", 60) )
Example #5
Source File: test_container.py From anyMesh-Python with MIT License | 6 votes |
def test_focus_path(self): # big tree of containers t = urwid.Text(u'x') e = urwid.Edit(u'?') c = urwid.Columns([t, e, t, t]) p = urwid.Pile([t, t, c, t]) a = urwid.AttrMap(p, 'gets ignored') s = urwid.SolidFill(u'/') o = urwid.Overlay(e, s, 'center', 'pack', 'middle', 'pack') lb = urwid.ListBox(urwid.SimpleFocusListWalker([t, a, o, t])) lb.focus_position = 1 g = urwid.GridFlow([t, t, t, t, e, t], 10, 0, 0, 'left') g.focus_position = 4 f = urwid.Frame(lb, header=t, footer=g) self.assertEqual(f.get_focus_path(), ['body', 1, 2, 1]) f.set_focus_path(['footer']) # same as f.focus_position = 'footer' self.assertEqual(f.get_focus_path(), ['footer', 4]) f.set_focus_path(['body', 1, 2, 2]) self.assertEqual(f.get_focus_path(), ['body', 1, 2, 2]) self.assertRaises(IndexError, lambda: f.set_focus_path([0, 1, 2])) self.assertRaises(IndexError, lambda: f.set_focus_path(['body', 2, 2])) f.set_focus_path(['body', 2]) # focus the overlay self.assertEqual(f.get_focus_path(), ['body', 2, 1])
Example #6
Source File: test_container.py From anyMesh-Python with MIT License | 6 votes |
def test_overlay(self): s1 = urwid.SolidFill(u'1') s2 = urwid.SolidFill(u'2') o = urwid.Overlay(s1, s2, 'center', ('relative', 50), 'middle', ('relative', 50)) self.assertEqual(o.focus, s1) self.assertEqual(o.focus_position, 1) self.assertRaises(IndexError, lambda: setattr(o, 'focus_position', None)) self.assertRaises(IndexError, lambda: setattr(o, 'focus_position', 2)) self.assertEqual(o.contents[0], (s2, urwid.Overlay._DEFAULT_BOTTOM_OPTIONS)) self.assertEqual(o.contents[1], (s1, ( 'center', None, 'relative', 50, None, 0, 0, 'middle', None, 'relative', 50, None, 0, 0)))
Example #7
Source File: main.py From bbj with MIT License | 6 votes |
def search_prompt(self): if self.mode == "index": callback = self.search_index_callback elif self.mode == "thread": callback = self.search_thread_callback else: return popup = OptionsMenu( urwid.ListBox( urwid.SimpleFocusListWalker([ urwid.Text(("button", "Enter a query:")), urwid.AttrMap(StringPrompt(callback), "opt_prompt"), urwid.Text("Use a blank query to reset the {}.".format(self.mode)) ])), **self.frame_theme()) self.loop.widget = urwid.Overlay( popup, self.loop.widget, align=("relative", 50), valign=("relative", 25 if self.window_split else 50), width=("relative", 40), height=6)
Example #8
Source File: main.py From bbj with MIT License | 6 votes |
def formatting_help(self, *_): """ Pops a help window for formatting directives. """ # we can "recycle" the server's formatting abilities to # use the same syntax for the help text itself message = network.fake_message( "\n\n".join(format_help), format="sequential") widget = OptionsMenu( urwid.ListBox(urwid.SimpleFocusListWalker(app.make_message_body(message, True))), **self.frame_theme("Formatting Help") ) va = 5 if self.window_split else 50 vh = 45 if self.window_split else 75 app.loop.widget = urwid.Overlay( widget, app.loop.widget, align=("relative", 50), valign=("relative", va), width=self.prefs["max_text_width"], height=("relative", vh) )
Example #9
Source File: test_container.py From anyMesh-Python with MIT License | 5 votes |
def test_old_params(self): o1 = urwid.Overlay(urwid.SolidFill(u'X'), urwid.SolidFill(u'O'), ('fixed left', 5), ('fixed right', 4), ('fixed top', 3), ('fixed bottom', 2),) self.assertEqual(o1.contents[1][1], ( 'left', None, 'relative', 100, None, 5, 4, 'top', None, 'relative', 100, None, 3, 2)) o2 = urwid.Overlay(urwid.SolidFill(u'X'), urwid.SolidFill(u'O'), ('fixed right', 5), ('fixed left', 4), ('fixed bottom', 3), ('fixed top', 2),) self.assertEqual(o2.contents[1][1], ( 'right', None, 'relative', 100, None, 4, 5, 'bottom', None, 'relative', 100, None, 2, 3))
Example #10
Source File: client.py From tildemush with GNU General Public License v3.0 | 5 votes |
def __init__(self, loop): self.loop = loop self.connection = None self.config = Config() self.ui = ui.UI(self.loop) self.listening = False self.authenticated = False self.ui.base = urwid.Overlay( urwid.Filler(urwid.Text('connecting..', align='center')), ui.solidfill('░', 'background'), align='center', width=15, valign='middle', height=3,)
Example #11
Source File: result.py From terminal-leetcode with MIT License | 5 votes |
def __init__(self, quiz, host_view, result, loop=None): self.quiz = quiz self.host_view = host_view self.result = result self.loop = loop self.logger = logging.getLogger(__name__) if result: if 'status_code' not in result: raise ValueError('Unknow result format: %s' % json.dumps(result)) if result['status_code'] == 20: self.listbox = self.make_compile_error_view() elif result['status_code'] == 10: self.listbox = self.make_success_view() elif result['status_code'] == 11: self.listbox = self.make_failed_view() elif result['status_code'] == 12: # memeory limit exceeded self.listbox = self.make_unified_error_view("Memory Limit Exceeded") elif result['status_code'] == 13: # output limit exceeded self.listbox = self.make_unified_error_view("Output Limit Exceeded") elif result['status_code'] == 14: # timeout self.listbox = self.make_unified_error_view("Time Limit Exceeded") elif result['status_code'] == 15: self.listbox = self.make_runtime_error_view() else: raise ValueError('Unknow status code: %d' % result['status_code']) else: raise ValueError('result shouldn\'t be None') self.overlay = urwid.Overlay( urwid.LineBox(self.listbox), host_view, align='center', width=('relative', 95), valign='middle', height=('relative', 95), min_width=40, min_height=40) footer = urwid.Pile([urwid.Text('Press Esc to close this view.', align='center'), urwid.Divider()]) urwid.Frame.__init__(self, self.overlay, footer=footer)
Example #12
Source File: loading.py From terminal-leetcode with MIT License | 5 votes |
def __init__(self, text, width, host_view, loop=None): self.running = False self.lock = EasyLock() self.loop = loop self.overlay = urwid.Overlay( urwid.LineBox(urwid.Text(text)), host_view, # urwid.SolidFill(), 'center', width, 'middle', None) urwid.Frame.__init__(self, self.overlay)
Example #13
Source File: loading.py From terminal-leetcode with MIT License | 5 votes |
def __init__(self, text, width, host_view, loop=None): self.loop = loop self.host_view = host_view self.overlay = urwid.Overlay( urwid.LineBox(urwid.Text(text)), host_view, # urwid.SolidFill(), 'center', width, 'middle', None) urwid.Frame.__init__(self, self.overlay)
Example #14
Source File: terminal.py From terminal-leetcode with MIT License | 5 votes |
def make_quit_confirmation(self): text = urwid.AttrMap(urwid.Text('Do you really want to quit ? (y/n)'), 'body') self.quit_confirm_view = urwid.Overlay(text, self.current_view, 'left', ('relative', 100), 'bottom', None) return self.quit_confirm_view
Example #15
Source File: terminal.py From terminal-leetcode with MIT License | 5 votes |
def make_submit_confirmation(self): text = urwid.AttrMap(urwid.Text('Do you want to submit your code ? (y/n)'), 'body') self.submit_confirm_view = urwid.Overlay(text, self.current_view, 'left', ('relative', 100), 'bottom', None) return self.submit_confirm_view
Example #16
Source File: manager_ui.py From sisyphus with Mozilla Public License 2.0 | 5 votes |
def setup_view(self): self.logger_box = urwid.SimpleListWalker([]) self._state_overview = urwid.Text("Starting") # ListBox self.job_box = urwid.ListBox(urwid.SimpleListWalker([])) w = urwid.Pile([urwid.AttrWrap(self.job_box, 'body')]) # Frame hdr = urwid.Text("Sisyphus | CWD: %s | Call: %s | Press h for help | press q or esc to quit" % (os.path.abspath('.'), ' '.join(sys.argv)), wrap='clip') self.header = hdr = urwid.AttrWrap(hdr, 'header') hdr = urwid.Pile([hdr, (10, urwid.AttrWrap(urwid.ListBox(self.logger_box), 'body')), urwid.AttrWrap(self._state_overview, 'note'), ]) self.setup_menu_view() self.main_view = self.menu_view self.job_view = urwid.Frame(header=hdr, body=w) # Exit message exit = urwid.BigText(('exit', " Quit? "), font=urwid.Thin6x6Font()) self.exit_view = urwid.Overlay(exit, w, 'center', None, 'middle', None) self.question_text = urwid.Text(" ") self.question_queue = Queue() self.question_sem = Semaphore() self.question_view = urwid.Overlay(self.question_text, self.main_view, 'center', ('relative', 80), 'middle', None) help = urwid.Text(help_text) self.help_view = urwid.Frame(header=self.header, body=urwid.ListBox([help])) self.setup_object_view() self.history = [] self.stop_job_view_update = False self.current_jobs = []
Example #17
Source File: base.py From ceph-ansible-copilot with GNU Lesser General Public License v2.1 | 5 votes |
def render_page(self): pb = urwid.Pile([ urwid.AttrMap( urwid.Filler( urwid.LineBox( urwid.ProgressBar('pg_normal', 'pg_complete', current=self.done, done=self.complete), title="Probing hosts")), 'pg_normal')]) w = urwid.Overlay(pb, self.bottom_w, align='center', valign='top', width=60, height=5, top=5) return w
Example #18
Source File: has_modal.py From Discurses with MIT License | 5 votes |
def __init__(self, main_widget): self._main_widget = main_widget self._pop_up = urwid.Frame(urwid.WidgetPlaceholder(None)) self._w_placeholder = urwid.WidgetPlaceholder(self._main_widget) self._pop_up_overlay = urwid.Overlay(urwid.LineBox(self._pop_up), self._main_widget, 'center', ('relative', 60), 'middle', ('relative', 60))
Example #19
Source File: songlist.py From clay with GNU General Public License v3.0 | 5 votes |
def __init__(self, app): self.app = app self.current_item = None self.tracks = [] self.walker = urwid.SimpleFocusListWalker([]) player.track_changed += self.track_changed player.media_state_changed += self.media_state_changed self.list_box = urwid.ListBox(self.walker) self.filter_prefix = '> ' self.filter_query = '' self.filter_box = urwid.Text(self.filter_prefix) self.filter_info = urwid.Text('') self.filter_panel = urwid.Columns([ self.filter_box, ('pack', self.filter_info) ]) self.content = urwid.Pile([ self.list_box, ]) self.overlay = urwid.Overlay( top_w=None, bottom_w=self.content, align='center', valign='middle', width=50, height='pack' ) self._is_filtering = False self.popup = None super(SongListBox, self).__init__( body=self.content )
Example #20
Source File: s_tui.py From s-tui with GNU General Public License v2.0 | 5 votes |
def on_graphs_menu_open(self, widget): """Open Sensor menu on top of existing frame""" self.original_widget = urwid.Overlay( self.graphs_menu.main_window, self.original_widget, ('relative', self.left_margin), self.graphs_menu.get_size()[1], ('relative', self.top_margin), self.graphs_menu.get_size()[0])
Example #21
Source File: test_container.py From anyMesh-Python with MIT License | 5 votes |
def test_get_cursor_coords(self): self.assertEqual(urwid.Overlay(urwid.Filler(urwid.Edit()), urwid.SolidFill(u'B'), 'right', 1, 'bottom', 1).get_cursor_coords((2,2)), (1,1))
Example #22
Source File: test_container.py From anyMesh-Python with MIT License | 5 votes |
def test_overlay(self): self.wstest(urwid.Overlay( urwid.BigText("hello",urwid.Thin6x6Font()), urwid.SolidFill(), 'center', None, 'middle', None)) self.wstest(urwid.Overlay( urwid.Text("hello"), urwid.SolidFill(), 'center', ('relative', 100), 'middle', None))
Example #23
Source File: app.py From toot with GNU General Public License v3.0 | 5 votes |
def async_delete_status(self, timeline, status): def _delete(): api.delete_status(self.app, self.user, status.id) def _done(loop): timeline.remove_status(status) return self.run_in_thread(_delete, done_callback=_done) # --- Overlay handling -----------------------------------------------------
Example #24
Source File: app.py From toot with GNU General Public License v3.0 | 5 votes |
def open_overlay(self, widget, options={}, title=""): top_widget = urwid.LineBox(widget, title=title) bottom_widget = self.body _options = self.default_overlay_options.copy() _options.update(options) self.overlay = urwid.Overlay( top_widget, bottom_widget, **_options ) self.body = self.overlay
Example #25
Source File: __main__.py From hangups with MIT License | 5 votes |
def _show_menu(self): """Show the overlay menu.""" # If the current widget in the TabbedWindowWidget has a menu, # overlay it on the TabbedWindowWidget. current_widget = self._tabbed_window.get_current_widget() if hasattr(current_widget, 'get_menu_widget'): menu_widget = current_widget.get_menu_widget(self._hide_menu) overlay = urwid.Overlay(menu_widget, self._tabbed_window, align='center', width=('relative', 80), valign='middle', height=('relative', 80)) self._urwid_loop.widget = overlay
Example #26
Source File: widgets.py From pycopia with Apache License 2.0 | 5 votes |
def _add_new(self, b): colname = self.metadata.colname relmodel = getattr(self.modelclass, colname).property.mapper.class_ newform = get_create_form(self.session, relmodel) urwid.connect_signal(newform, 'popform', self._popsubform) urwid.connect_signal(newform, 'message', self._message) ovl = urwid.Overlay(urwid.LineBox(newform), self._w, "center", ("relative", 90), "middle", ("relative", 90), min_width=40, min_height=20) self._w = ovl
Example #27
Source File: core.py From zulip-terminal with Apache License 2.0 | 5 votes |
def show_pop_up(self, to_show: Any) -> None: double_lines = dict(tlcorner='╔', tline='═', trcorner='╗', rline='║', lline='║', blcorner='╚', bline='═', brcorner='╝') self.loop.widget = urwid.Overlay( urwid.LineBox(to_show, to_show.title, **double_lines), self.view, align='center', valign='middle', # +2 to both of the following, due to LineBox width=to_show.width + 2, height=to_show.height + 2, )
Example #28
Source File: __init__.py From conjure-up with MIT License | 5 votes |
def show_shutdown_dialog(self, exit_code): self.frame.body = Overlay(ShutdownView(exit_code), self.frame.body, 'center', ('relative', 45), 'middle', 'pack')
Example #29
Source File: main.py From bbj with MIT License | 5 votes |
def overlay_p(self): """ Return True or False if the current widget is an overlay. """ return isinstance(self.loop.widget, urwid.Overlay)
Example #30
Source File: main.py From bbj with MIT License | 5 votes |
def remove_overlays(self, *_): """ Remove ALL urwid.Overlay objects which are currently covering the base widget. """ while True: try: self.loop.widget = self.loop.widget[0] except: break