Python urwid.WidgetPlaceholder() Examples
The following are 8
code examples of urwid.WidgetPlaceholder().
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: components.py From sclack with GNU General Public License v3.0 | 6 votes |
def __init__(self, user, typing=None, is_read_only=False): self.read_only_widget = urwid.Text('You have no power here!', align='center') if typing != None: top_separator = TextDivider(('is_typing', '{} {} is typing...'.format( get_icon('keyboard'), typing ))) else: top_separator = urwid.Divider('─') self.prompt_widget = MessagePrompt(user) middle = urwid.WidgetPlaceholder(self.read_only_widget if is_read_only else self.prompt_widget) self.body = urwid.Pile([ urwid.WidgetPlaceholder(top_separator), middle, urwid.Divider('─') ]) self._typing = typing super(MessageBox, self).__init__(self.body, None, {'prompt': 'active_prompt'})
Example #2
Source File: message.py From sclack with GNU General Public License v3.0 | 6 votes |
def __init__(self, ts, channel_id, user, text, indicators, reactions=(), attachments=()): self.ts = ts self.channel_id = channel_id self.user_id = user.id self.markdown_text = text self.original_text = text.original_text self.text_widget = urwid.WidgetPlaceholder(text) main_column = [urwid.Columns([('pack', user), self.text_widget])] main_column.extend(attachments) self._file_index = len(main_column) if reactions: main_column.append(urwid.Columns([ ('pack', reaction) for reaction in reactions ])) self.main_column = urwid.Pile(main_column) columns = [ ('fixed', 7, Time(ts)), self.main_column, ('fixed', indicators.size, indicators) ] self.contents = urwid.Columns(columns) super(Message, self).__init__(self.contents, None, { None: 'active_message', 'message': 'active_message' })
Example #3
Source File: __main__.py From mlbstreamer with GNU General Public License v2.0 | 6 votes |
def __init__(self, provider, date): self.game_date = date self.toolbar = Toolbar() urwid.connect_signal( self.toolbar, "provider_change", lambda w, p: self.set_provider(p) ) self.table_placeholder = urwid.WidgetPlaceholder(urwid.Text("")) self.datebar = DateBar(self.game_date) # self.table = GamesDataTable(self.toolbar.sport_id, self.game_date) # preseason self.pile = urwid.Pile([ (1, self.toolbar), (1, self.datebar), ("weight", 1, self.table_placeholder) ]) self.pile.focus_position = 2 super(ScheduleView, self).__init__(self.pile) self.set_provider(provider)
Example #4
Source File: __main__.py From mlbstreamer with GNU General Public License v2.0 | 5 votes |
def __init__(self): # self.league_dropdown = Dropdown(AttrDict([ # ("MLB", 1), # ("AAA", 11), # ]) , label="League") self.provider_dropdown = Dropdown(AttrDict( [ (p.upper(), p) for p in session.PROVIDERS] ) , label="Provider", margin=1) urwid.connect_signal( self.provider_dropdown, "change", lambda w, b, v: self._emit("provider_change", v) ) self.live_stream_dropdown = Dropdown([ "live", "from start" ], label="Live streams") self.resolution_dropdown_placeholder = urwid.WidgetPlaceholder(urwid.Text("")) self.columns = urwid.Columns([ ('weight', 1, self.provider_dropdown), ('weight', 1, self.live_stream_dropdown), ('weight', 1, self.resolution_dropdown_placeholder), # ("weight", 1, urwid.Padding(urwid.Text(""))) ]) self.filler = urwid.Filler(self.columns) super(Toolbar, self).__init__(self.filler)
Example #5
Source File: complex_bar_graph.py From s-tui with GNU General Public License v2.0 | 5 votes |
def __init__(self, title, sub_title_list, y_label, bar_graph_vector, visible_graph_list): for bar_graph in bar_graph_vector: if not isinstance(bar_graph, ScalableBarGraph): raise Exception( 'graph vector items must be ScalableBarGraph') if not self.check_label(y_label): raise Exception( 'Y label must be a valid label') self.visible_graph_list = visible_graph_list self.bar_graph_vector = [] self.set_graph(bar_graph_vector) self.y_label_and_graphs = urwid.WidgetPlaceholder(urwid.Columns([])) self.y_label = [] self.set_y_label(y_label) list_w = urwid.ListBox(urwid.SimpleFocusListWalker([])) self.title = urwid.WidgetPlaceholder(list_w) self.sub_title_list = sub_title_list self.set_title(title) super(LabeledBarGraphVector, self).__init__(urwid.Pile([])) self.set_visible_graphs(visible_graph_list)
Example #6
Source File: complex_bar_graph.py From s-tui with GNU General Public License v2.0 | 5 votes |
def set_visible_graphs(self, visible_graph_list=None): """Show a column of the graph selected for display""" if visible_graph_list is None: visible_graph_list = self.visible_graph_list vline = urwid.AttrWrap(urwid.SolidFill(u'|'), 'line') graph_vector_column_list = [] for state, graph, sub_title in zip(visible_graph_list, self.bar_graph_vector, self.sub_title_list): if state: text_w = urwid.Text(sub_title, align='center') sub_title_widget = urwid.ListBox([text_w]) graph_a = [('fixed', 1, sub_title_widget), ('weight', 1, graph)] graph_and_title = urwid.Pile(graph_a) graph_vector_column_list.append(('weight', 1, graph_and_title)) graph_vector_column_list.append(('fixed', 1, vline)) # if all sub graph are disabled if not graph_vector_column_list: self.visible_graph_list = visible_graph_list self.original_widget = urwid.Pile([]) return # remove the last vertical line separator graph_vector_column_list.pop() y_label_a = ('weight', 1, urwid.Columns(graph_vector_column_list)) y_label_and_graphs = [self.y_label, y_label_a] column_w = urwid.Columns(y_label_and_graphs, dividechars=1) y_label_and_graphs_widget = urwid.WidgetPlaceholder(column_w) init_widget = urwid.Pile([('fixed', 1, self.title), ('weight', 1, y_label_and_graphs_widget)]) self.visible_graph_list = visible_graph_list self.original_widget = init_widget
Example #7
Source File: s_tui.py From s-tui with GNU General Public License v2.0 | 5 votes |
def __init__(self, controller): # constants self.left_margin = 0 self.top_margin = 0 # main control self.controller = controller self.main_window_w = [] # general urwid items self.clock_view = urwid.Text(ZERO_TIME, align="center") self.refresh_rate_ctrl = urwid.Edit((u'Refresh[s]:'), self.controller.refresh_rate) self.hline = urwid.AttrWrap(urwid.SolidFill(u' '), 'line') self.mode_buttons = [] self.summary_widget_index = None # Visible graphs are the graphs currently displayed, this is a # subset of the available graphs for display self.graph_place_holder = urwid.WidgetPlaceholder(urwid.Pile([])) # construct the various menus during init phase self.stress_menu = StressMenu(self.on_menu_close, self.controller.stress_exe) self.help_menu = HelpMenu(self.on_menu_close) self.about_menu = AboutMenu(self.on_menu_close) self.graphs_menu = SensorsMenu(self.on_graphs_menu_close, self.controller.sources, self.controller.graphs_default_conf) self.summary_menu = SensorsMenu(self.on_summary_menu_close, self.controller.sources, self.controller.summary_default_conf) # call super urwid.WidgetPlaceholder.__init__(self, self.main_window()) urwid.connect_signal(self.refresh_rate_ctrl, 'change', self.update_refresh_rate)
Example #8
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))