Python urwid 模块,SolidFill() 实例源码

我们从Python开源项目中,提取了以下22个代码示例,用于说明如何使用urwid.SolidFill()

项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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)))
项目:mongoaudit    作者:Exploit-install    | 项目源码 | 文件源码
def setup_view(self):
        placeholder = urwid.SolidFill()
        self.loop = urwid.MainLoop(
            placeholder, PALETTE, unhandled_input=self.key_handler)
        self.loop.widget = urwid.AttrMap(placeholder, 'bg')
        #self.loop.widget._command_map['tab'] = 'cursor down'
        #self.loop.widget._command_map['shift tab'] = 'cursor up'
        self.loop.screen.set_terminal_properties(colors=256)
        self.cards.welcome()
项目:mongoaudit    作者:stampery    | 项目源码 | 文件源码
def setup_view(self):
        placeholder = urwid.SolidFill()
        self.loop = urwid.MainLoop(
            placeholder, PALETTE, unhandled_input=self.key_handler)
        self.loop.widget = urwid.AttrMap(placeholder, 'bg')
        #self.loop.widget._command_map['tab'] = 'cursor down'
        #self.loop.widget._command_map['shift tab'] = 'cursor up'
        self.loop.screen.set_terminal_properties(colors=256)
        self.cards.welcome()
项目:douban-movie    作者:chishui    | 项目源码 | 文件源码
def __init__(self, movies):
        footer=urwid.AttrWrap(urwid.Text('Press q to exit, use up and down arrow to navigate, press Enter to select'), 'footer')
        items = self.make_items(movies)
        self.listbox = urwid.ListBox(urwid.SimpleListWalker(items))
        top = urwid.Overlay(self.listbox, urwid.SolidFill(' '),
            align='center', width=('relative', 60),
            valign='middle', height=('relative', 60),
            min_width=20, min_height=9)
        urwid.Frame.__init__(self, urwid.AttrWrap(top, 'body'), footer=footer)
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def __init__(self, box):
        super(CascadingBoxes, self).__init__(urwid.SolidFill(u'/'))
        self.box_level = 0
        self.open_box(box)
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def main_shadow(self, w):
        """Wrap a shadow and background around widget w."""
        bg = urwid.AttrWrap(urwid.SolidFill(u"\u2592"), 'screen edge')
        shadow = urwid.AttrWrap(urwid.SolidFill(u" "), 'main shadow')

        bg = urwid.Overlay( shadow, bg,
            ('fixed left', 3), ('fixed right', 1),
            ('fixed top', 2), ('fixed bottom', 1))
        w = urwid.Overlay( w, bg,
            ('fixed left', 2), ('fixed right', 3),
            ('fixed top', 1), ('fixed bottom', 2))
        return w
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def main_window(self):
        self.graph = self.bar_graph()
        self.graph_wrap = urwid.WidgetWrap( self.graph )
        vline = urwid.AttrWrap( urwid.SolidFill(u'\u2502'), 'line')
        c = self.graph_controls()
        w = urwid.Columns([('weight',2,self.graph_wrap),
            ('fixed',1,vline), c],
            dividechars=1, focus_column=2)
        w = urwid.Padding(w,('fixed left',1),('fixed right',0))
        w = urwid.AttrWrap(w,'body')
        w = urwid.LineBox(w)
        w = urwid.AttrWrap(w,'line')
        w = self.main_shadow(w)
        return w
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def main_shadow(self, w):
        """Wrap a shadow and background around widget w."""
        bg = urwid.AttrWrap(urwid.SolidFill(u"\u2592"), 'screen edge')
        shadow = urwid.AttrWrap(urwid.SolidFill(u" "), 'main shadow')

        bg = urwid.Overlay( shadow, bg,
            ('fixed left', 3), ('fixed right', 1),
            ('fixed top', 2), ('fixed bottom', 1))
        w = urwid.Overlay( w, bg,
            ('fixed left', 2), ('fixed right', 3),
            ('fixed top', 1), ('fixed bottom', 2))
        return w
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def main_window(self):
        self.graph = self.bar_graph()
        self.graph_wrap = urwid.WidgetWrap( self.graph )
        vline = urwid.AttrWrap( urwid.SolidFill(u'\u2502'), 'line')
        c = self.graph_controls()
        w = urwid.Columns([('weight',2,self.graph_wrap),
            ('fixed',1,vline), c],
            dividechars=1, focus_column=2)
        w = urwid.Padding(w,('fixed left',1),('fixed right',0))
        w = urwid.AttrWrap(w,'body')
        w = urwid.LineBox(w)
        w = urwid.AttrWrap(w,'line')
        w = self.main_shadow(w)
        return w
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_old_attributes(self):
        c = urwid.Columns([urwid.Text(u'a'), urwid.SolidFill(u'x')],
            box_columns=[1])
        self.assertEqual(c.box_columns, [1])
        c.box_columns=[]
        self.assertEqual(c.box_columns, [])
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_solidfill(self):
        self.wstest(urwid.SolidFill())
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
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))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_pile(self):
        self.wstest(urwid.Pile([urwid.SolidFill()]))
        self.wstest(urwid.Pile([('flow', urwid.Text("hello"))]))
        self.wstest(urwid.Pile([]))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_columns(self):
        self.wstest(urwid.Columns([urwid.SolidFill()]))
        self.wstest(urwid.Columns([(4, urwid.SolidFill())]))
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_frame(self):
        s1 = urwid.SolidFill(u'1')

        f = urwid.Frame(s1)
        self.assertEqual(f.focus, s1)
        self.assertEqual(f.focus_position, 'body')
        self.assertRaises(IndexError, lambda: setattr(f, 'focus_position',
            None))
        self.assertRaises(IndexError, lambda: setattr(f, 'focus_position',
            'header'))

        t1 = urwid.Text(u'one')
        t2 = urwid.Text(u'two')
        t3 = urwid.Text(u'three')
        f = urwid.Frame(s1, t1, t2, 'header')
        self.assertEqual(f.focus, t1)
        self.assertEqual(f.focus_position, 'header')
        f.focus_position = 'footer'
        self.assertEqual(f.focus, t2)
        self.assertEqual(f.focus_position, 'footer')
        self.assertRaises(IndexError, lambda: setattr(f, 'focus_position', -1))
        self.assertRaises(IndexError, lambda: setattr(f, 'focus_position', 2))
        del f.contents['footer']
        self.assertEqual(f.footer, None)
        self.assertEqual(f.focus_position, 'body')
        f.contents.update(footer=(t3, None), header=(t2, None))
        self.assertEqual(f.header, t2)
        self.assertEqual(f.footer, t3)
        def set1():
            f.contents['body'] = t1
        self.assertRaises(urwid.FrameError, set1)
        def set2():
            f.contents['body'] = (t1, 'given')
        self.assertRaises(urwid.FrameError, set2)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
def show_loading(self, text, width, host_view=urwid.SolidFill()):
        self.loading_view = LoadingView(text, width, host_view, self.loop)
        self.loop.widget = self.loading_view
        self.loading_view.start()
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
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)
项目:terminal-leetcode    作者:chishui    | 项目源码 | 文件源码
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)
项目:stellarmagnate    作者:abadger    | 项目源码 | 文件源码
def __init__(self, pubpen):
        self.pubpen = pubpen
        self.display_stack = []
        self.blank = LineBox(urwid.SolidFill(' '), lline=None,
                             blcorner='?', tlcorner='?',
                             trcorner='\u252c', brcorner='\u2524')
        self.background = urwid.WidgetPlaceholder(self.blank)

        super().__init__(self.background)

        # Widgets traded in and out of the main display area

        self.market_display = MarketDisplay(self.pubpen)
        self.cargo_order_dialog = CargoOrderDialog(self.pubpen)
        self.travel_menu = TravelDisplay(self.pubpen)
        self.game_menu = GameMenuDialog(self.pubpen)
        self.port_display = PortDisplay(self.pubpen)
        self.equip_order_dialog = EquipOrderDialog(self.pubpen)
        self.financial_display = FinancialDisplay(self.pubpen)

        self.display_map = {
            'MarketDisplay': self.market_display,
            'CargoOrderDialog': self.cargo_order_dialog,
            'PortDisplay': self.port_display,
            'EquipOrderDialog': self.equip_order_dialog,
            'FinancialDisplay': self.financial_display,
            'TravelDisplay': self.travel_menu,
            'GameMenuDialog': self.game_menu,
            'Blank': self.blank
            }

        self.dialogs = frozenset(n for n in self.display_map if n.endswith('Dialog'))

        self.push_display('Blank')

        urwid.connect_signal(self.market_display, 'close_market_display', self.pop_display)
        urwid.connect_signal(self.market_display, 'open_cargo_order_dialog',
                             partial(self.push_display, 'CargoOrderDialog'))
        urwid.connect_signal(self.cargo_order_dialog, 'close_cargo_order_dialog', self.pop_display)
        urwid.connect_signal(self.port_display, 'open_equip_order_dialog',
                             partial(self.push_display, 'EquipOrderDialog'))
        urwid.connect_signal(self.equip_order_dialog, 'close_equip_order_dialog', self.pop_display)
        urwid.connect_signal(self.travel_menu, 'close_travel_menu', self.pop_display)
        urwid.connect_signal(self.game_menu, 'close_game_menu', self.pop_display)
项目:Adwear    作者:Uberi    | 项目源码 | 文件源码
def test_pile(self):
        t1 = urwid.Text(u'one')
        t2 = urwid.Text(u'two')
        t3 = urwid.Text(u'three')
        sf = urwid.SolidFill('x')
        p = urwid.Pile([])
        self.assertEqual(p.focus, None)
        self.assertRaises(IndexError, lambda: getattr(p, 'focus_position'))
        self.assertRaises(IndexError, lambda: setattr(p, 'focus_position',
            None))
        self.assertRaises(IndexError, lambda: setattr(p, 'focus_position', 0))
        p.contents = [(t1, ('pack', None)), (t2, ('pack', None)),
            (sf, ('given', 3)), (t3, ('pack', None))]
        p.focus_position = 1
        del p.contents[0]
        self.assertEqual(p.focus_position, 0)
        p.contents[0:0] = [(t3, ('pack', None)), (t2, ('pack', None))]
        p.contents.insert(3, (t1, ('pack', None)))
        self.assertEqual(p.focus_position, 2)
        self.assertRaises(urwid.PileError, lambda: p.contents.append(t1))
        self.assertRaises(urwid.PileError, lambda: p.contents.append((t1, None)))
        self.assertRaises(urwid.PileError, lambda: p.contents.append((t1, 'given')))

        p = urwid.Pile([t1, t2])
        self.assertEqual(p.focus, t1)
        self.assertEqual(p.focus_position, 0)
        p.focus_position = 1
        self.assertEqual(p.focus, t2)
        self.assertEqual(p.focus_position, 1)
        p.focus_position = 0
        self.assertRaises(IndexError, lambda: setattr(p, 'focus_position', -1))
        self.assertRaises(IndexError, lambda: setattr(p, 'focus_position', 2))
        # old methods:
        p.set_focus(0)
        self.assertRaises(IndexError, lambda: p.set_focus(-1))
        self.assertRaises(IndexError, lambda: p.set_focus(2))
        p.set_focus(t2)
        self.assertEqual(p.focus_position, 1)
        self.assertRaises(ValueError, lambda: p.set_focus('nonexistant'))
        self.assertEqual(p.widget_list, [t1, t2])
        self.assertEqual(p.item_types, [('weight', 1), ('weight', 1)])
        p.widget_list = [t2, t1]
        self.assertEqual(p.widget_list, [t2, t1])
        self.assertEqual(p.contents, [(t2, ('weight', 1)), (t1, ('weight', 1))])
        self.assertEqual(p.focus_position, 1) # focus unchanged
        p.item_types = [('flow', None), ('weight', 2)]
        self.assertEqual(p.item_types, [('flow', None), ('weight', 2)])
        self.assertEqual(p.contents, [(t2, ('pack', None)), (t1, ('weight', 2))])
        self.assertEqual(p.focus_position, 1) # focus unchanged
        p.widget_list = [t1]
        self.assertEqual(len(p.contents), 1)
        self.assertEqual(p.focus_position, 0)
        p.widget_list.extend([t2, t1])
        self.assertEqual(len(p.contents), 3)
        self.assertEqual(p.item_types, [
            ('flow', None), ('weight', 1), ('weight', 1)])
        p.item_types[:] = [('weight', 2)]
        self.assertEqual(len(p.contents), 1)