def _mk_tail_canv(self, direction, icon): unit = {'bit': 'b', 'byte': 'B'}[objects.localcfg['unit.bandwidth']] text = urwid.Text('%s/s %s' % (unit, icon)) attr_text = urwid.AttrMap(text, 'bottombar.bandwidth.%s' % direction) return attr_text.render((self._TAIL_WIDTH,))
def prompt(self, prefix, text=u'', completer=None, tab=0, history=None): """ prompt for text input. This returns a :class:`asyncio.Future`, which will have a string value :param prefix: text to print before the input field :type prefix: str :param text: initial content of the input field :type text: str :param completer: completion object to use :type completer: :meth:`alot.completion.Completer` :param tab: number of tabs to press initially (to select completion results) :type tab: int :param history: history to be used for up/down keys :type history: list of str :rtype: asyncio.Future """ history = history or [] fut = asyncio.Future() oldroot = self.mainloop.widget def select_or_cancel(text): """Restore the main screen and invoce the callback (delayed return) with the given text.""" self.mainloop.widget = oldroot self._passall = False fut.set_result(text) def cerror(e): logging.error(e) self.notify('completion error: %s' % str(e), priority='error') self.update() prefix = prefix + settings.get('prompt_suffix') # set up widgets leftpart = urwid.Text(prefix, align='left') editpart = CompleteEdit(completer, on_exit=select_or_cancel, edit_text=text, history=history, on_error=cerror) for _ in range(tab): # hit some tabs editpart.keypress((0, ), 'tab') # build promptwidget both = urwid.Columns([ ('fixed', len(prefix), leftpart), ('weight', 1, editpart), ]) att = settings.get_theming_attribute('global', 'prompt') both = urwid.AttrMap(both, att) # put promptwidget as overlay on main widget overlay = urwid.Overlay(both, oldroot, ('fixed left', 0), ('fixed right', 0), ('fixed bottom', 1), None) self.mainloop.widget = overlay self._passall = True return fut
def choice(self, message, choices=None, select=None, cancel=None, msg_position='above', choices_to_return=None): """ prompt user to make a choice. :param message: string to display before list of choices :type message: unicode :param choices: dict of possible choices :type choices: dict: keymap->choice (both str) :param choices_to_return: dict of possible choices to return for the choices of the choices of paramter :type choices: dict: keymap->choice key is str and value is any obj) :param select: choice to return if enter/return is hit. Ignored if set to `None`. :type select: str :param cancel: choice to return if escape is hit. Ignored if set to `None`. :type cancel: str :param msg_position: determines if `message` is above or left of the prompt. Must be `above` or `left`. :type msg_position: str :rtype: asyncio.Future """ choices = choices or {'y': 'yes', 'n': 'no'} assert select is None or select in choices.values() assert cancel is None or cancel in choices.values() assert msg_position in ['left', 'above'] fut = asyncio.Future() # Create a returned future oldroot = self.mainloop.widget def select_or_cancel(text): """Restore the main screen and invoce the callback (delayed return) with the given text.""" self.mainloop.widget = oldroot self._passall = False fut.set_result(text) # set up widgets msgpart = urwid.Text(message) choicespart = ChoiceWidget(choices, choices_to_return=choices_to_return, callback=select_or_cancel, select=select, cancel=cancel) # build widget if msg_position == 'left': both = urwid.Columns([ ('fixed', len(message), msgpart), ('weight', 1, choicespart), ], dividechars=1) else: # above both = urwid.Pile([msgpart, choicespart]) att = settings.get_theming_attribute('global', 'prompt') both = urwid.AttrMap(both, att, att) # put promptwidget as overlay on main widget overlay = urwid.Overlay(both, oldroot, ('fixed left', 0), ('fixed right', 0), ('fixed bottom', 1), None) self.mainloop.widget = overlay self._passall = True return fut
class Status(_COLUMNS['status'], CellWidgetBase): style = Style(prefix='trackerlist.status', focusable=True, extras=('header', )) header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['status'].header), style.attrs('header'))
def __init__(self, caption: Any, email: str = '') -> None: self.caption = caption # str self.email = email super(MenuButton, self).__init__("") self._w = urwid.AttrMap(urwid.SelectableIcon([self.caption], 0), None, 'selected')
def process_urls(self, extractedurls, dedupe, shorten): """Process the 'extractedurls' and ready them for either the curses browser or non-interactive output Args: extractedurls dedupe - Remove duplicate URLs from list Returns: items - List of widgets for the ListBox urls - List of all URLs """ cols, _ = urwid.raw_display.Screen().get_cols_rows() items = [] urls = [] first = True for group, usedfirst, usedlast in extractedurls: if first: first = False items.append(urwid.Divider(div_char='-', top=1, bottom=1)) if dedupe is True: # If no unique URLs exist, then skip the group completely if not [ chunk for chunks in group for chunk in chunks if chunk.url is not None and chunk.url not in urls ]: continue groupurls = [] markup = [] if not usedfirst: markup.append(('msgtext:ellipses', '...\n')) for chunks in group: i = 0 while i < len(chunks): chunk = chunks[i] i += 1 if chunk.url is None: markup.append(chunk.markup) else: if (dedupe is True and chunk.url not in urls) \ or dedupe is False: urls.append(chunk.url) groupurls.append(chunk.url) # Collect all immediately adjacent # chunks with the same URL. tmpmarkup = [] if chunk.markup: tmpmarkup.append(chunk.markup) while i < len(chunks) and \ chunks[i].url == chunk.url: if chunks[i].markup: tmpmarkup.append(chunks[i].markup) i += 1 url_idx = urls.index( chunk.url) + 1 if dedupe is True else len(urls) markup += [ tmpmarkup or '<URL>', ('urlref:number:braces', ' ['), ('urlref:number', repr(url_idx)), ('urlref:number:braces', ']') ] markup += '\n' if not usedlast: markup += [('msgtext:ellipses', '...\n\n')] items.append(urwid.Text(markup)) i = len(urls) - len(groupurls) for url in groupurls: i += 1 markup = [(6, urwid.Text([('urlref:number:braces', '['), ('urlref:number', repr(i)), ('urlref:number:braces', ']'), ' '])), urwid.AttrMap( urwid.Button(shorten_url(url, cols, shorten), self.mkbrowseto(url), user_data=url), 'urlref:url', 'url:sel')] items.append(urwid.Columns(markup)) return items, urls
def __init__(self, context, oldnew, comment): super(UnifiedDiffComment, self).__init__([]) self.context = context text = urwid.AttrMap(urwid.Text(comment), 'comment') self.contents.append((urwid.Text(u''), ('given', 8, False))) self.contents.append((text, ('weight', 1, False)))
iinfo=iinfo)) self.main_widget_list.append( VariableWidget(prefix, var_label, value_str, id_path, attr_prefix, iinfo=iinfo)) # }}} # {{{ top level SEPARATOR = urwid.AttrMap(urwid.Text(""), "variable separator") def make_var_view(frame_var_info, locals, globals): vars = list(locals.keys()) vars.sort(key=lambda n: n.lower()) tmv_walker = TopAndMainVariableWalker(frame_var_info) ret_walker = BasicValueWalker(frame_var_info) watch_widget_list = [] for watch_expr in frame_var_info.watches: try: value = eval(watch_expr.expression, globals, locals) except: value = WatchEvalError()
#!/usr/bin/env python3 import urwid def exit_on_q(key): if key in ('q', 'Q'): raise urwid.ExitMainLoop() palette = [ ('banner', 'black', 'light gray'), ('streak', 'black', 'dark red'), ('bg', 'black', 'dark blue'), ] txt = urwid.Text([('banner', " " * 10), ""], align='center') map1 = urwid.AttrMap(txt, 'streak') fill = urwid.Filler(map1) map2 = urwid.AttrMap(fill, 'bg') loop = urwid.MainLoop(map2, palette, unhandled_input=exit_on_q) loop.run()
class Port(_COLUMNS['port'], CellWidgetBase): style = Style(prefix='peerlist.port', focusable=False, extras=('header', )) header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['port'].header), style.attrs('header'))
def cat_widget(cands): return urwid.AttrMap(urwid.Padding(cat_widget_cols(cands)), 'completion.category', 'default')
def update(self, keymap, context, active_keychains, keys_given): active_keychains = list(active_keychains) self._pile.contents[:] = [] if not active_keychains: return # Find number of keychain columns key_col_num = max(len(kc) for kc,action in active_keychains) # Find widest key for each column (each key is in its own cell) key_col_widths = [0] * key_col_num for kc,action in active_keychains: for colnum in range(key_col_num): try: width = len(kc[colnum]) except IndexError: width = 0 key_col_widths[colnum] = max(key_col_widths[colnum], width) # Total key chain column width is: # max(len(key) for each key) + (1 space between keys) key_col_width = sum(key_col_widths) + key_col_num - 1 # Create list of rows keychain_col_width = max(len(self._headers[0]), key_col_width) spacer = ('pack' , urwid.Text(' ')) rows = [ # First row is the headers urwid.AttrMap(urwid.Columns([ (keychain_col_width, urwid.Text(self._headers[0])), spacer, urwid.Text(self._headers[1]), spacer, urwid.Text(self._headers[2]), ]), 'keychains.header') ] next_key_index = len(keys_given) if len(active_keychains) > 10: active_keychains = self._compress_keychains(active_keychains, next_key_index) for kc,action in sorted(active_keychains, key=lambda x: str(x[0]).lower()): row = [] for colnum in range(key_col_num): colwidth = key_col_widths[colnum] try: keytext = kc[colnum].ljust(colwidth) except IndexError: # This keychain is shorter than the longest one row.append(('pack', urwid.Text(('keychains.keys', ''.ljust(colwidth))))) else: # Highlight the key the user needs to press to advance keychain attrs = ('keychains.keys.next' if colnum == next_key_index else 'keychains.keys') row.append(('pack', urwid.Text((attrs, keytext)))) # Add space between this key cell and the next unless this is the last column if colnum < key_col_num - 1: row.append(('pack', urwid.Text(('keychains.keys', ' ')))) # Fill remaining space if 'Key Chain' header is longer than all key chains remaining_width = keychain_col_width - key_col_width row.append(('pack', urwid.Text(('keychains.keys', ''.ljust(remaining_width))))) row.append(spacer) row.append(urwid.AttrMap(urwid.Text(str(action)), 'keychains.action')) row.append(spacer) row.append(urwid.AttrMap(urwid.Text(keymap.get_description(kc, context)), 'keychains.description')) rows.append(urwid.Columns(row)) options = self._pile.options('pack') for row in rows: self._pile.contents.append((row, options))
def __init__(self): self._text = urwid.Text(EMPTY_TEXT) super().__init__(urwid.AttrMap(self._text, 'bottombar')) objects.srvapi.status.on_update(self._update_counters)
def __init__(self): self._pile = urwid.Pile([]) super().__init__(urwid.AttrMap(self._pile, 'keychains'))
def _populate_completion(self): widget_list = self.tooltip.body while widget_list: widget_list.pop() # This is just me flailing around wildly. TODO: actually write. if self.complete(): if self.funcprops: # This is mostly just stolen from the cli module. func_name, args, is_bound = self.funcprops in_arg = self.arg_pos args, varargs, varkw, defaults = args[:4] if py3: kwonly = self.funcprops.argspec.kwonly kwonly_defaults = self.funcprops.argspec.kwonly_defaults or {} else: kwonly, kwonly_defaults = [], {} markup = [('bold name', func_name), ('name', ': (')] # the isinstance checks if we're in a positional arg # (instead of a keyword arg), I think if is_bound and isinstance(in_arg, int): in_arg += 1 # bpython.cli checks if this goes off the edge and # does clever wrapping. I do not (yet). for k, i in enumerate(args): if defaults and k + 1 > len(args) - len(defaults): kw = repr(defaults[k - (len(args) - len(defaults))]) else: kw = None if not k and str(i) == 'self': color = 'name' else: color = 'token' if k == in_arg or i == in_arg: color = 'bold ' + color if not py3: # See issue #138: We need to format tuple unpacking correctly # We use the undocumented function inspection.strseq() for # that. Fortunately, that madness is gone in Python 3. markup.append((color, inspect.strseq(i, str))) else: markup.append((color, str(i))) if kw is not None: markup.extend([('punctuation', '='), ('token', kw)]) if k != len(args) - 1: markup.append(('punctuation', ', ')) if varargs: if args: markup.append(('punctuation', ', ')) markup.append(('token', '*' + varargs)) if kwonly: if not varargs: if args: markup.append(('punctuation', ', ')) markup.append(('punctuation', '*')) for arg in kwonly: if arg == in_arg: color = 'bold token' else: color = 'token' markup.extend([('punctuation', ', '), (color, arg)]) if arg in kwonly_defaults: markup.extend([('punctuation', '='), ('token', kwonly_defaults[arg])]) if varkw: if args or varargs or kwonly: markup.append(('punctuation', ', ')) markup.append(('token', '**' + varkw)) markup.append(('punctuation', ')')) widget_list.append(urwid.Text(markup)) if self.matches_iter.matches: attr_map = {} focus_map = {'main': 'operator'} texts = [urwid.AttrMap(urwid.Text(('main', match)), attr_map, focus_map) for match in self.matches_iter.matches] width = max(text.original_widget.pack()[0] for text in texts) gridflow = urwid.GridFlow(texts, width, 1, 0, 'left') widget_list.append(gridflow) self.tooltip.grid = gridflow self.overlay.tooltip_focus = False else: self.tooltip.grid = None self.frame.body = self.overlay else: self.frame.body = self.listbox self.tooltip.grid = None if self.docstring: # TODO: use self.format_docstring? needs a width/height... docstring = self.docstring widget_list.append(urwid.Text(('comment', docstring)))
def _create_head_section(self): grid = [] contents = [] contents.append((18, urwid.AttrMap(urwid.Text(u'Name'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['SPECIFIC_NAME']), 'editbox')) grid.append(urwid.Columns(contents)) contents = [] contents.append( (18, urwid.AttrMap(urwid.Text(u'Definer'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['DEFINER']), 'editbox')) grid.append(urwid.Columns(contents)) contents = [] contents.append((18, urwid.AttrMap(urwid.Text(u'Type'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['ROUTINE_TYPE']), 'editbox')) grid.append(urwid.Columns(contents)) contents = [] contents.append( (18, urwid.AttrMap(urwid.Text(u'Data access'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['SQL_DATA_ACCESS']), 'editbox')) grid.append(urwid.Columns(contents)) if (self._model['ROUTINE_TYPE'] == 'FUNCTION'): contents = [] contents.append( (18, urwid.AttrMap(urwid.Text(u'Returns'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['DTD_IDENTIFIER']), 'editbox')) grid.append(urwid.Columns(contents)) contents = [] contents.append( (18, urwid.AttrMap(urwid.Text(u'SQL Security'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['SECURITY_TYPE']), 'editbox')) grid.append(urwid.Columns(contents)) contents = [] contents.append((18, urwid.AttrMap(urwid.Text(u'Is deterministic?'), 'editbox:label'))) contents.append( urwid.AttrMap(urwid.Text(self._model['IS_DETERMINISTIC']), 'editbox')) grid.append(urwid.Columns(contents)) grid = urwid.GridFlow(grid, cell_width=40, h_sep=1, v_sep=1, align='left') return grid
def __init__(self, widget: urwid.Widget) -> None: wdg = urwid.AttrMap(widget, "li normal", "li focus") super().__init__(wdg)
def create_title_widgets(self): self.title_text = urwid.BigText("Bank Statement Wizard", BIG_TEXT_FONT) self.title = SwitchingPadding(self.title_text, "center", None) self.title = urwid.Filler(self.title, "middle") self.title = urwid.BoxAdapter(self.title, self.title_box_height) self.title = urwid.AttrMap(self.title, "title")
def __init__(self, text, on_press=None, user_data=None): super(TextButton, self).__init__('', on_press=on_press, user_data=user_data) self.text = urwid.Text(text) self._w = urwid.AttrMap(self.text, None, focus_map='focused')
def __init__(self) -> None: self.left = urwid.Text("") self.right = urwid.Text("", align="right") self.cols = urwid.Columns([("pack", self.left), ("weight", 1, self.right)]) self._indicators = {} super().__init__(urwid.AttrMap(self.cols, "topbar"))
class Marked(MarkedBase): style = Style(prefix='filelist.marked', focusable=True, extras=('header',)) header = urwid.AttrMap(ColumnHeaderWidget(), style.attrs('header'))
def __init__(self) -> None: super().__init__(urwid.AttrMap(urwid.Divider(), "bg"))
def rebuild(self): cols = [] if self.thread: newest = self.thread.get_newest_date() else: newest = None if newest == None: datestring = '' else: datestring = settings.represent_datetime(newest) datestring = datestring.rjust(self.pretty_datetime_len) self.date_w = urwid.AttrMap(urwid.Text(datestring), self._get_theme('date')) cols.append(('fixed', len(datestring), self.date_w)) if self.thread: mailcountstring = "(%d)" % self.thread.get_total_messages() else: mailcountstring = "(?)" self.mailcount_w = urwid.AttrMap(urwid.Text(mailcountstring), self._get_theme('mailcount')) cols.append(('fixed', len(mailcountstring), self.mailcount_w)) if self.thread: self.tag_widgets = [TagWidget(t) for t in self.thread.get_tags()] else: self.tag_widgets = [] self.tag_widgets.sort(tag_cmp, lambda tag_widget: tag_widget.translated) for tag_widget in self.tag_widgets: if not tag_widget.hidden: cols.append(('fixed', tag_widget.width(), tag_widget)) if self.thread: authors = self.thread.get_authors_string() or '(None)' else: authors = '(None)' maxlength = settings.get('authors_maxlength') authorsstring = shorten_author_string(authors, maxlength) self.authors_w = urwid.AttrMap(urwid.Text(authorsstring), self._get_theme('authors')) cols.append(('fixed', len(authorsstring), self.authors_w)) if self.thread: subjectstring = self.thread.get_subject() or '' else: subjectstring = '' # sanitize subject string: subjectstring = subjectstring.replace('\n', ' ') subjectstring = subjectstring.replace('\r', '') subjectstring = subjectstring.strip() self.subject_w = urwid.AttrMap(urwid.Text(subjectstring, wrap='clip'), self._get_theme('subject')) if subjectstring: cols.append(('weight', 2, self.subject_w)) if self.display_content: if self.thread: msgs = self.thread.get_messages().keys() else: msgs = [] # sort the most recent messages first msgs.sort(key=lambda msg: msg.get_date(), reverse=True) lastcontent = ' '.join([m.get_text_content() for m in msgs]) contentstring = lastcontent.replace('\n', ' ').strip() self.content_w = urwid.AttrMap( urwid.Text(contentstring, wrap='clip'), self._get_theme('content')) cols.append(self.content_w) self.columns = urwid.Columns(cols, dividechars=1) self.original_widget = self.columns
def item_chosen(button, choice): response = urwid.Text([u'You chose ', choice, u'\n']) done = urwid.Button(u'Ok') urwid.connect_signal(done, 'click', exit_program) main.original_widget = urwid.Filler(urwid.Pile([response, urwid.AttrMap(done, None, focus_map='reversed')]))
def selection(bouton, choice): response = urwid.Text('Votre sélection: {}\n'.format(choice)) done = urwid.Button('Valider') urwid.connect_signal(done, 'click', sortie) padding.original_widget = urwid.Filler( urwid.Pile([response, urwid.AttrMap(done, None)]))
def update_chan_list(self): # refresh of chan list self.chan_list = urwid.SimpleFocusListWalker( [urwid.AttrMap(urwid.Text("Chan list:"), 'status_bar')]) super().__init__(self.chan_list) if self.Telegram_ui.current_chan == []: self.Telegram_ui.current_chan = self.chans[-1] pos = self.focus_position i = len(self.chans) - 1 # build of chan list for chan in self.chans[::-1]: pos += 1 print_name = chan['print_name'] cmd = chan['id'] label = print_name.replace('_', ' ') if chan['peer_type'] == 'user': label = "➜ " + label elif chan['peer_type'] == 'chat': label = "➜➜ " + label elif chan['peer_type'] == 'channel': label = "⤨ " + label if cmd in self.msg_chan and self.msg_chan[cmd] != 0: label = label + ' [' + str(self.msg_chan[cmd]) + ']' if print_name == self.Telegram_ui.current_chan['print_name']: button = NewButton(('cur_chan', label), self.chan_change, chan) current_pos = pos self.current_chan_pos = i else: button = NewButton(label, self.chan_change, chan) self.chan_list.insert(pos, button) i -= 1 if not 'current_pos' in locals(): self.current_chan_pos = 1 current_pos = pos - 1 pos += 1 self.chan_list.insert(pos, urwid.AttrMap(urwid.Divider('─'), 'separator')) #pos += 1 #self.chan_list.insert(pos, urwid.Text('✚ Create new group chat')) #pos += 1 #self.chan_list.insert(pos, urwid.Text('✚ Create new channel')) #pos += 1 #self.chan_list.insert(pos, urwid.Text('☺ Contacts')) #pos += 1 #self.chan_list.insert(pos, urwid.AttrMap(urwid.Divider('─'), 'separator')) # print of buffer button only if needed list_buff = [cmd for cmd in self.Telegram_ui.msg_buffer.keys()] list_chan = [chan['id'] for chan in self.chans] list_buff.sort() list_chan.sort() if list_buff != list_chan: pos += 1 button = NewButton('⬇ Download message buffer', self.Telegram_ui.fill_msg_buffer) self.chan_list.insert(pos, button) self.focus_position = current_pos
def __init__(self, dbman, initialcmdline): """ :param dbman: :class:`~alot.db.DBManager` :param initialcmdline: commandline applied after setting up interface :type initialcmdline: str :param colourmode: determines which theme to chose :type colourmode: int in [1,16,256] """ self.dbman = dbman """Database Manager (:class:`~alot.db.manager.DBManager`)""" self.buffers = [] """list of active buffers""" self.current_buffer = None """points to currently active :class:`~alot.buffers.Buffer`""" self.db_was_locked = False """flag used to prevent multiple 'index locked' notifications""" self.mode = 'global' """interface mode identifier - type of current buffer""" self.commandprompthistory = [] """history of the command line prompt""" self.senderhistory = [] """history of the sender prompt""" self.recipienthistory = [] """history of the recipients prompt""" self.input_queue = [] """stores partial keyboard input""" self.last_commandline = None """saves the last executed commandline""" # define empty notification pile self._notificationbar = None # should we show a status bar? self._show_statusbar = settings.get('show_statusbar') # pass keypresses to the root widget and never interpret bindings self._passall = False # indicates "input lock": only focus move commands are interpreted self._locked = False self._unlock_callback = None # will be called after input lock ended self._unlock_key = None # key that ends input lock # alarm handle for callback that clears input queue (to cancel alarm) self._alarm = None # force urwid to pass key events as unicode, independent of LANG urwid.set_encoding('utf-8') # create root widget global_att = settings.get_theming_attribute('global', 'body') mainframe = urwid.Frame(urwid.SolidFill()) self.root_widget = urwid.AttrMap(mainframe, global_att) signal.signal(signal.SIGINT, self.handle_signal) signal.signal(signal.SIGUSR1, self.handle_signal) # load histories self._cache = os.path.join( get_xdg_env('XDG_CACHE_HOME', os.path.expanduser('~/.cache')), 'alot', 'history') self._cmd_hist_file = os.path.join(self._cache, 'commands') self._sender_hist_file = os.path.join(self._cache, 'senders') self._recipients_hist_file = os.path.join(self._cache, 'recipients') size = settings.get('history_size') self.commandprompthistory = self._load_history_from_file( self._cmd_hist_file, size=size) self.senderhistory = self._load_history_from_file( self._sender_hist_file, size=size) self.recipienthistory = self._load_history_from_file( self._recipients_hist_file, size=size) # set up main loop self.mainloop = urwid.MainLoop( self.root_widget, handle_mouse=settings.get('handle_mouse'), event_loop=urwid.AsyncioEventLoop(), unhandled_input=self._unhandled_input, input_filter=self._input_filter) loop = asyncio.get_event_loop() # Create a task for the periodic hook loop_hook = settings.get_hook('loop_hook') if loop_hook: # In Python 3.7 a nice aliase `asyncio.create_task` was added loop.create_task( periodic(loop_hook, settings.get('periodic_hook_frequency'), ui=self)) # set up colours colourmode = int(settings.get('colourmode')) logging.info('setup gui in %d colours', colourmode) self.mainloop.screen.set_terminal_properties(colors=colourmode) logging.debug('fire first command') loop.create_task(self.apply_commandline(initialcmdline)) # start urwids mainloop self.mainloop.run()
def __init__(self, caption, callback, arg=None): super(NewButton, self).__init__("") urwid.connect_signal(self, 'click', callback, arg) self._w = urwid.AttrMap(urwid.SelectableIcon(caption, 1), None, focus_map='status_bar')
def build_line(msg, prio): cols = urwid.Columns([urwid.Text(msg)]) att = settings.get_theming_attribute('global', 'notify_' + prio) return urwid.AttrMap(cols, att)
def mkattr(text, attrsname): return urwid.AttrMap(urwid.Padding(text), attrsname)