def __init__(self, data, provider, label="channels"): self.label = label self.provider = provider self.placeholder = urwid.WidgetPlaceholder(urwid.Filler( urwid.Text(""))) self.channel_count_placeholder = urwid.WidgetPlaceholder( urwid.Text("")) self.header = urwid.Filler( urwid.AttrMap( urwid.Columns( [("pack", urwid.Text(self.provider.CHANNELS_LABEL)), ("weight", 1, self.channel_count_placeholder)], dividechars=1), "header")) self.footer = ChannelTreeFooter(self) self.pile = urwid.Pile([(1, self.header), ("weight", 1, self.placeholder), (1, self.footer)]) super().__init__(self.pile) self.pile.selectable = lambda: True self.load()
def create(self) -> urwid.Widget: ui = CheckForUpdatesWidget(self.opkg_tools, self.shell.screen, self) urwid.connect_signal(ui, "continue", self._on_continue) urwid.connect_signal(ui, "exit", self._on_exit) self.check_for_updates_wdg = ui self.content = urwid.WidgetPlaceholder(ui) self.frame = urwid.Frame(self.content, header=widget.ActivityHeader("System update")) return self.frame
def init(): global widget global parent global main global palette global loop widget = urwid.WidgetPlaceholder(None) main = urwid.Filler(urwid.Padding(widget, left=5, right=5)) loop = urwid.MainLoop(main, palette) parent = None
def __init__(self, table, index=None, border=None, padding=None, cell_selection=False, *args, **kwargs): self.table = table self.index = index self.border = border self.padding = padding self.cell_selection = cell_selection self.sort = self.table.sort_by self.attr = self.ATTR self.attr_focused = "%s focused" %(self.attr) self.attr_column_focused = "%s column_focused" %(self.attr) self.attr_highlight = "%s highlight" %(self.attr) self.attr_highlight_focused = "%s focused" %(self.attr_highlight) self.attr_highlight_column_focused = "%s column_focused" %(self.attr_highlight) self.attr_map = { None: self.attr, } self.focus_map = { self.attr: self.attr_focused, self.attr_highlight: self.attr_highlight_focused, } # needed to restore if cell selection is toggled self.original_focus_map = self.focus_map.copy() # if self.cell_selection: self.focus_map.update({ self.attr_focused: self.attr_column_focused, self.attr_highlight_focused: self.attr_highlight_column_focused, }) self.focus_map.update(self.table.column_focus_map) self.cell_selection_focus_map = self.focus_map.copy() if cell_selection: self.enable_cell_selection() else: self.disable_cell_selection() self.focus_map.update(table.focus_map) self.columns_placeholder = urwid.WidgetPlaceholder(urwid.Text("")) self.attrmap = urwid.AttrMap( self.columns_placeholder, attr_map = self.attr_map, focus_map = self.focus_map, ) self.update() super(DataTableRow, self).__init__(self.attrmap)
def _create_opkg_update_screen(self) -> urwid.Widget: self.message_line = urwid.WidgetPlaceholder( urwid.AttrMap(urwid.Text("Checking for updates..."), "progress")) update_term = urwid.LineBox( self._create_update_terminal(), title="opkg update", title_align="left", ) content = urwid.Pile([("pack", self.message_line), ("pack", urwid.Divider()), update_term]) return content
def __init__(self, connection, **args): self.connection = connection self.view = 'Contents' self._cached_tables = {} self.footer_status = args['footer_status'] table_contents = TableContentsWidget(connection, None) self.widget = urwid.WidgetPlaceholder( urwid.LineBox(table_contents, title="No table selected") ) urwid.WidgetWrap.__init__(self, self.widget)
def startui(urwidloop) -> None: # Show the splash screen as soon as possible urwidloop.draw_screen() # We can now import and show the main menu screen container = urwid.WidgetPlaceholder(urwid.SolidFill(" ")) urwidloop.widget = urwid.AttrMap(container, "bg") from compman.ui.mainmenu import MainMenuScreen screen = MainMenuScreen(container) screen.on_exit(exit) screen.show()
def __init__(self, menuClass): fill = urwid.WidgetPlaceholder( #urwid.SolidFill(u' ') urwid.AttrMap(urwid.SolidFill(u'░'), 'background')) super(UWApplication, self).__init__(fill) # u'▒' u'░' self.menuInstances = None self.menuBar = None self.fill = fill self.fillOriginalWidget = fill.original_widget self.currMenuId = -1 self.register_menu(menuClass) self.set_focus_path(['header', 0])
async def run(): placeholder = urwid.WidgetPlaceholder( urwid.Filler(urwid.Text("Initialize..."))) with urwid.MainLoop( urwid.LineBox(placeholder), event_loop=urwid.AsyncioEventLoop(), handle_mouse=False, ).start(): def widget_cb(widget): placeholder.original_widget = widget await main_menu(widget_cb)
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)
def __init__(self): self.main_view = MainView() self.root = urwid.WidgetPlaceholder(self.main_view) self.loop = urwid.MainLoop( self.root, handle_mouse=False, unhandled_input=self.unhandled_input, palette=theme["palette"], ) self.inputfd = self.loop.watch_pipe(self._input_reader) self._inputpipe = InputPipe(self.inputfd) self.start()
def __init__(self, provider): self.provider = provider self.browser_placeholder = urwid.WidgetPlaceholder(urwid.Text("")) self.pile = urwid.Pile([ ('weight', 1, self.browser_placeholder), ]) super().__init__(self.browser_placeholder) self.pile.focus_position = 0 self.updated = False self.storyboard_lock = asyncio.Lock() self.prefix_re = None self.prefix_scope = 0 state.event_loop.create_task(self.check_updated())
def create(self) -> urwid.Widget: btxt = urwid.BigText("Openvario", urwid.font.Thin6x6Font()) logo = urwid.Padding(btxt, "center", "clip") m_pinned_apps = self._get_pinned_apps() if m_pinned_apps: m_pinned_apps.append(urwid.Divider()) m_apps = widget.SelectableListItem("Applications") urwid.connect_signal(m_apps, "click", self._on_apps) m_settings = widget.SelectableListItem("Settings") urwid.connect_signal(m_settings, "click", self._on_settings) m_shutdown = widget.SelectableListItem("Shut down") urwid.connect_signal(m_shutdown, "click", self._on_quit) menu = urwid.Pile( m_pinned_apps + [m_apps, m_settings, urwid.Divider(), m_shutdown] ) # Reserve space for counter self.autostart_counter = urwid.WidgetPlaceholder( urwid.BoxAdapter(urwid.SolidFill(" "), 2) ) view = urwid.Filler( urwid.Pile( [ logo, urwid.Text(self._get_version(), align=urwid.CENTER), urwid.Divider(), urwid.Padding( urwid.LineBox(menu, "Main Menu", title_align="left"), width=("relative", 40), align=urwid.CENTER, ), urwid.Divider(), urwid.Divider(), self.autostart_counter, ] ), "middle", ) self.autostart_canceller = AutostartCanceller(view) urwid.connect_signal( self.autostart_canceller, "anykey", self._on_cancel_autostart ) view = widget.KeySignals(self.autostart_canceller) urwid.connect_signal(view, "cancel", self._on_quit) return view
def __init__(self): self.root_widget = urwid.WidgetPlaceholder(urwid.SolidFill('')) self.builder: Builder = Builder(self.root_widget) # Since our main purpose is to insert stuff in the tty command line, we send the screen to STDERR # so we can capture stdout easily without swapping file descriptors screen = urwid.raw_display.Screen(output=sys.stderr) self.main_loop = urwid.MainLoop( self.root_widget, handle_mouse=False, pop_ups=True, palette=theme.palette, screen=screen, event_loop=urwid.AsyncioEventLoop(loop=get_event_loop()), unhandled_input=self._on_unhandled_input, ) self.main_loop.screen.set_terminal_properties(colors=256)
def _create_opkg_update_screen(self) -> urwid.Widget: self.message_line = urwid.WidgetPlaceholder( urwid.AttrMap(urwid.Text("Checking for updates..."), "progress")) update_term = urwid.LineBox( self._create_update_terminal(), title="opkg update", title_align="left", ) content = urwid.Pile([("pack", self.message_line), ("pack", urwid.Divider()), update_term]) # Force pack to be selectable, even though no widget is selectable at # the moment. content._selectable = True return content
def create(self) -> urwid.Widget: self.content = urwid.Filler(urwid.Padding(urwid.Text(""))) self.title = urwid.Text("") self.step = urwid.WidgetPlaceholder(urwid.SolidFill(" ")) self.content_pile = urwid.Pile([("pack", self.title), ("pack", urwid.Divider()), self.step]) self.frame = urwid.Frame( self.content_pile, header=widget.ActivityHeader("Setup wizard"), ) self._switch_step(0) return self.frame
def __init__(self, manager): self.reminder = Reminder() self.manager = manager self.header_text = 'Set a reminder for:\n' self.div = '\n--------------------------' self.header = urwid.Text('Set a reminder for:' +\ self.div, 'center') self.holder = urwid.WidgetPlaceholder(urwid.Filler(urwid.Text(''))) self.frame = urwid.Frame(self.holder, header=self.header) self.box_adapter = urwid.BoxAdapter(self.frame, self.get_height()) line_box = urwid.LineBox(self.box_adapter) overlay = urwid.Overlay(line_box, manager, 'center', 30, 'middle', 'pack') super().__init__(overlay) self.start_reminder()
def __init__(self): self.db_conn = connect_db() _ids = get_game_ids() self.size = len(_ids) self.banner_games = asyncio.run( batch_game_create(_ids, 'banner', self.db_conn)) # sizing self.screen = urwid.raw_display.Screen() (self.cols, self.rows) = self.screen.get_cols_rows() self._sizing() # footer and progress bar self.header = urwid.WidgetPlaceholder(create_header()) # top bar self._populate_hidden() self.game_panel = GamePanel(self, self.tb_rows) self.main_menu = create_main_menu(self, self.tb_rows) self.top_bar = urwid.Columns( [('weight', 1, self.main_menu), ('weight', 4, self.game_panel)], dividechars=1, ) # main display self.context = None self.context_menu = create_opening_menu(self.main_rows) self.display = create_opening_page(self.main_rows) self.main_display = urwid.Columns([('weight', 1, self.context_menu), ('weight', 4, self.display)], dividechars=1) self.list_walk = urwid.SimpleFocusListWalker( [self.top_bar, self.main_display]) self.body = urwid.ListBox(self.list_walk) self.frame = urwid.Frame(urwid.AttrWrap(self.body, 'main'), header=urwid.AttrWrap(self.header, 'main')) self.loop = urwid.MainLoop(self.frame, palette=PALETTE, screen=self.screen, pop_ups=True)
def __init__(self, provider): self.provider = provider self.toolbar = MainToolbar(self.provider.IDENTIFIER) urwid.connect_signal(self.toolbar, "provider_change", lambda w, p: self.set_provider(p)) urwid.connect_signal(self.toolbar, "profile_change", lambda w, p: config.settings.set_profile(p)) self.browser_view_placeholder = urwid.WidgetPlaceholder( urwid.Filler(urwid.Text(""))) self.pile = urwid.Pile([ (1, self.toolbar), (1, urwid.Filler(urwid.Divider("-"))), ('weight', 1, self.browser_view_placeholder), ]) super().__init__(self.pile)
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)
def __init__(self): self.header_txt = urwid.Text("tBB - Command Line Front-end", 'center') self.header_txt = urwid.AttrWrap(self.header_txt, 'header') self.header_date = urwid.Text("{}", 'left') self.header_date = urwid.AttrWrap(self.header_date, 'header') self.header_time = urwid.Text("{}", 'right') self.header_time = urwid.AttrWrap(self.header_time, 'header') self.commands = urwid.Columns([ urwid.AttrWrap(urwid.Text("[esc|q: Exit]", 'left'), 'header buttons'), urwid.AttrWrap(urwid.Text("[w: Back]", 'center'), 'header buttons'), urwid.AttrWrap(urwid.Text("[e: Next]", 'center'), 'header buttons'), urwid.AttrWrap(urwid.Text("[F5|r: Refresh]", 'center'), 'header buttons'), urwid.AttrWrap(urwid.Text("[h: Help]", 'right'), 'header buttons'), ]) self.nav_position = urwid.AttrWrap(urwid.Text("ASD > asd"), 'navigation') self.header = urwid.Pile([ urwid.Columns([ self.header_date, ('weight', 2, self.header_txt), self.header_time, ]), self.commands, urwid.AttrWrap(urwid.Divider(div_char='━'), 'header'), self.nav_position, ]) self.placeholder = urwid.WidgetPlaceholder(urwid.Text("Placeholder")) self.body_history = {} self.current_view = 0 self.status = urwid.AttrWrap(urwid.Text(""), 'footer') # footer self.reset_status() self.footer = urwid.Pile([ urwid.AttrWrap(urwid.Divider(div_char='━'), 'header'), self.status ]) super().__init__( body=urwid.AttrWrap(self.placeholder, 'body'), header=self.header, footer=self.footer, ) asyncio. async (self.keep_time_updated())
def _make_file_picker(self, fileinfo: FileInfo) -> urwid.Widget: statusw = self._dl_in_progress.get(fileinfo.name) if statusw is None: st = urwid.Text(" New " if not fileinfo.downloaded else "") statusw = urwid.WidgetPlaceholder(st) fmtsize = format_size(fileinfo.size) cols = urwid.Columns([ ("weight", 2, urwid.Text(fileinfo.name)), ("weight", 1, urwid.Text(fmtsize + " ", align="right")), ("weight", 1, statusw), ]) w = widget.SelectableItem(cols) urwid.connect_signal(w, "click", self._file_clicked, user_args=[fileinfo, statusw]) return w
def create(self) -> urwid.Widget: # view = urwid.SolidFill("*") self._svc_walker = urwid.SimpleFocusListWalker([urwid.Text("")]) self._techs_ph = urwid.WidgetPlaceholder(urwid.Text("")) view = urwid.Pile( [ ("pack", self._techs_ph), ("pack", urwid.Divider()), ("pack", self._make_service_header()), urwid.ListBox(self._svc_walker), ] ) self.frame = urwid.Frame( view, header=widget.ActivityHeader("Network connections") ) return self.frame
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 clock_text = seconds_to_text(self.controller.stress_time) self.clock_view = urwid.Text(('bold text', clock_text), align="center") self.refresh_rate_ctrl = urwid.Edit(('bold text', u'Refresh[s]:'), self.controller.refresh_rate) self.hline = urwid.AttrWrap(urwid.SolidFill(u'_'), 'line') self.mode_buttons = [] # Visible graphs are the graphs currently displayed, this is a # subset of the available graphs for display self.visible_graphs = {} self.graph_place_holder = urwid.WidgetPlaceholder(urwid.Pile([])) # construct sources possible_source = [TempSource(self.controller.temp_thresh), FreqSource(), UtilSource(), RaplPowerSource()] self.source_list = [s for s in possible_source if s.get_is_available()] # construct the variouse menus during init phase self.stress_menu = StressMenu(self.on_menu_close) self.help_menu = HelpMenu(self.on_menu_close) self.about_menu = AboutMenu(self.on_menu_close) self.sensors_menu = SensorsMenu(self.on_sensors_menu_close, self.source_list) self.global_data = GlobalData(is_admin) self.stress_menu.sqrt_workers = str(self.global_data.num_cpus) # call super urwid.WidgetPlaceholder.__init__(self, self.main_window()) urwid.connect_signal(self.refresh_rate_ctrl, 'change', self.update_refresh_rate)
def create_layout(self): self.postlist = PostListDisplay() urwid.connect_signal(self.postlist.walker, 'open_link', self.update_content) urwid.connect_signal(self.postlist.walker, 'open_comments', self.update_content) # command prompt self.prompt = urwid.Edit('> ') # menu bar self.menubar = urwid.Pile([ urwid.AttrMap( urwid.Columns([ ('pack', urwid.AttrMap(urwid.SelectableIcon(' file '), None, focus_map='titlebar_active')), ('pack', urwid.AttrMap(urwid.SelectableIcon(' options '), None, focus_map='titlebar_active')) ]), 'titlebar'), urwid.Divider() ]) # content display self.display_content = urwid.WidgetPlaceholder( urwid.LineBox( urwid.Filler( urwid.Text(('inactive', '[no content selected]'), align='center')))) # frame self.frame = urwid.Frame(urwid.Columns([ urwid.Filler(self.postlist, height=('relative', 100)), self.display_content ]), header=self.menubar, footer=urwid.AttrMap(self.prompt, None, focus_map='active'))
def __init__(self, controller, args): self.controller = controller self.custom_temp = args.custom_temp self.hline = urwid.AttrWrap(urwid.SolidFill(u'_'), 'line') self.mode_buttons = [] self.visible_graphs = {} self.graph_place_holder = urwid.WidgetPlaceholder(urwid.Pile([])) self.main_window_w = [] self.stress_menu = StressMenu(self.on_menu_close) self.help_menu = HelpMenu(self.on_menu_close) self.about_menu = AboutMenu(self.on_menu_close) self.global_data = GlobalData(is_admin) self.stress_menu.sqrt_workers = str(self.global_data.num_cpus) urwid.WidgetPlaceholder.__init__(self, self.main_window())
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
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)
def __init__(self, config): self._configure(config) self._subsources_list_iter = itertools.cycle(self._subsources_list) self.listbox_w = w = urwid.ListBox(urwid.SimpleFocusListWalker([])) w._command_map = CommandMap( { "k": "cursor up", "up": "cursor up", "j": "cursor down", "down": "cursor down", } ) self.content_wrapper = w = urwid.WidgetPlaceholder(w) w = linebox(w, self._default_title) self._linebox_w = w.original_widget # XXX: not elegant urwid.WidgetWrap.__init__(self, w) self.next_subsource()
def __init__( self, top_dir=None, cwd=None, root=None, dir_sort=None, file_sort=None, ignore_files=False, ignore_directories=False, # no_parent_dir=False, expand_empty=False): self.top_dir = os.path.normpath(top_dir or os.getcwd()) cwd = cwd or self.top_dir self.root = root if not isinstance(dir_sort, (tuple, list)): dir_sort = (dir_sort, False) if not isinstance(file_sort, (tuple, list)): file_sort = (file_sort, False) self._dir_sort = dir_sort self._file_sort = file_sort self.ignore_files = ignore_files self.ignore_directories = ignore_directories # self.no_parent_dir = no_parent_dir self.expand_empty = expand_empty self.last_selection = None self.placeholder = urwid.WidgetPlaceholder(urwid.Filler( urwid.Text(""))) self.pile = urwid.Pile([("weight", 1, self.placeholder)]) super().__init__(self.pile) self.pile.selectable = lambda: True self.change_directory(self.top_dir) if cwd: node = self.find_path(os.path.relpath(cwd, self.top_dir)) if node: self.listbox.set_focus(node)