| 2 | |
| 3 | |
| 4 | class Tab(urwid.WidgetWrap): |
| 5 | def __init__(self, offset, content, attr, onclick): |
| 6 | """ |
| 7 | onclick is called on click with the tab offset as argument |
| 8 | """ |
| 9 | p = urwid.Text(content, align="center") |
| 10 | p = urwid.Padding(p, align="center", width=("relative", 100)) |
| 11 | p = urwid.AttrMap(p, attr) |
| 12 | urwid.WidgetWrap.__init__(self, p) |
| 13 | self.offset = offset |
| 14 | self.onclick = onclick |
| 15 | |
| 16 | def mouse_event(self, size, event, button, col, row, focus): |
| 17 | if event == "mouse press" and button == 1: |
| 18 | self.onclick(self.offset) |
| 19 | return True |
| 20 | |
| 21 | |
| 22 | class Tabs(urwid.WidgetWrap): |