예제 #1
0
 def setUp(self):
     self.pile = urwid.Pile([
         urwid.Text(line) for line in TEXT
     ])
     self.scrollable = Scrollable(self.pile)
     self.scrollbar = ScrollBar(self.scrollable,
                                thumb_char='#', trough_char='|')
예제 #2
0
    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|||',
        ))
예제 #3
0
    def test_wrapping_bug(self):
        scrl = Scrollable(
            urwid.Pile([urwid.Columns([urwid.Text("long text")] * 2)] * 2)
        )
        sb = ScrollBar(scrl, thumb_char='#', trough_char='|', width=3)
        widget = urwid.Columns([urwid.Pile([urwid.LineBox(sb)])] * 2)

        self.check(widget, (9, 6), cursor_pos=(), text=(
            '┌───┐┌──┐',
            '│###││##│',
            '│###││##│',
            '│###││##│',
            '│###││##│',
            '└───┘└──┘',
        ))
예제 #4
0
    def test_mouse_event(self):
        scrl = Scrollable(
            urwid.Pile([
                urwid.Text('t1'),
                urwid.Text('t2'),
                urwid.Edit('', 'eXXX'),
                urwid.Text('t3'),
                urwid.Edit('', 'eYYY'),
                urwid.Text('t4'),
                urwid.Text('t5')
            ]))
        sb = ScrollBar(scrl, thumb_char='#', trough_char='|')

        size = (10, 5)
        self.check(sb,
                   size,
                   cursor_pos=(4, 2),
                   text=('t1'.ljust(size[0] - 1) + '#',
                         't2'.ljust(size[0] - 1) + '#',
                         'eXXX'.ljust(size[0] - 1) + '#',
                         't3'.ljust(size[0] - 1) + '#',
                         'eYYY'.ljust(size[0] - 1) + '|'))

        sb.mouse_event(size, 'mouse press', button=1, col=1, row=4, focus=True)
        self.check(sb,
                   size,
                   cursor_pos=(1, 4),
                   text=('t1'.ljust(size[0] - 1) + '#',
                         't2'.ljust(size[0] - 1) + '#',
                         'eXXX'.ljust(size[0] - 1) + '#',
                         't3'.ljust(size[0] - 1) + '#',
                         'eYYY'.ljust(size[0] - 1) + '|'))

        scrl.set_scrollpos(2)
        self.check(sb,
                   size,
                   cursor_pos=(1, 2),
                   text=('eXXX'.ljust(size[0] - 1) + '|',
                         't3'.ljust(size[0] - 1) + '#',
                         'eYYY'.ljust(size[0] - 1) + '#',
                         't4'.ljust(size[0] - 1) + '#',
                         't5'.ljust(size[0] - 1) + '#'))

        sb.mouse_event(size, 'mouse press', button=1, col=3, row=0, focus=True)
        self.check(sb,
                   size,
                   cursor_pos=(3, 0),
                   text=('eXXX'.ljust(size[0] - 1) + '|',
                         't3'.ljust(size[0] - 1) + '#',
                         'eYYY'.ljust(size[0] - 1) + '#',
                         't4'.ljust(size[0] - 1) + '#',
                         't5'.ljust(size[0] - 1) + '#'))
예제 #5
0
 def test_empty_widget(self):
     for w in (ScrollBar(Scrollable(urwid.Text(''))),
               ScrollBar(Scrollable(urwid.Pile([])))):
         self.check(w, size=(5, 10), text=(' ' * 5,) * 10)