Ejemplo n.º 1
0
    def __init__(self):
        header = urwid.AttrWrap(urwid.Text(('banner',
                                            ' .oO Bandwidth Monitor Oo. '),
                                           align='center'),
                                'header')
        self.status = urwid.Text(('banner', ' Ready '), align='right')
        help_text = 'Use arrow keys to scroll the list and move to the' \
                ' buttons. Press "q" to quit.'
        footer = urwid.AttrWrap(urwid.Columns([urwid.Text(help_text),
                                               self.status]),
                                'footer')

        self.start = urwid.Text(('date', ''), align='right')
        self.end = urwid.Text(('date', datetime.date.today() \
                                       .strftime('  %d %B %Y  ')),
                              align='left')
        dates = urwid.Filler(urwid.Columns([
            self.start, urwid.Text(' to ', align='center'), self.end,
        ]), ('fixed top', 1))

        thead, tfoot = [], []
        self.total = {}
        for label in ['Booted at', 'Uptime', 'Received', 'Transmitted', 'Total']:
            thead.append(urwid.AttrWrap(urwid.Text(label, align='right'),
                                        'thead'))
            self.total[label] = urwid.Text('', align='right')
            tfoot.append(urwid.AttrWrap(self.total[label], 'tfoot'))
        self.total['Booted at'].set_text('Total')
        thead = urwid.Filler(urwid.Columns(thead, 1, min_width=12))
        tfoot = urwid.Filler(urwid.Columns(tfoot, 1, min_width=12))

        self.tbody = urwid.ListBox([])
        qbutton = urwid.Filler(urwid.Columns([
#            urwid.Padding(urwid.AttrWrap(urwid.Button('Settings',
#                                                      self.settings_dialog),
#                                         'button normal', 'button select'),
#                          'right', 12),
            urwid.Divider('~'),
            urwid.Padding(urwid.AttrWrap(urwid.Button('Quit', self.quit),
                                         'button normal', 'button select'),
                          'center', 8),
            urwid.Divider('~')], 3))
        body = urwid.AttrMap(urwid.Pile([
            ('fixed', 3, dates),
            ('fixed', 1, thead),
            self.tbody,
            ('fixed', 1, tfoot),
            ('fixed', 3, qbutton)
        ]), 'bg')
        super(MainView, self).__init__(body=body, header=header, footer=footer)

        for settings in Settings.select():
            self.settings = settings
            break
        else:
            now = datetime.datetime.now()
            start = datetime.datetime(year=now.year, month=now.month, day=1)
            self.settings = Settings(start=start)

        self.populate()
Ejemplo n.º 2
0
 def __init__(self, parent=None):
     super(BandwidthTableModel, self).__init__(parent)
     self.header = [
         QCoreApplication.translate('ifmon', 'Booted at'),
         QCoreApplication.translate('ifmon', 'Uptime'),
         QCoreApplication.translate('ifmon', 'Recieved'),
         QCoreApplication.translate('ifmon', 'Transmitted'),
         QCoreApplication.translate('ifmon', 'Total')
     ]
     for settings in Settings.select():
         self.settings = settings
         break
     else:
         now = datetime.now()
         start = datetime(year=now.year, month=now.month, day=1)
         self.settings = Settings(start=start)
     self.populateData()
Ejemplo n.º 3
0
    def __init__(self):
        header = urwid.AttrWrap(
            urwid.Text(('banner', ' .oO Bandwidth Monitor Oo. '),
                       align='center'), 'header')
        self.status = urwid.Text(('banner', ' Ready '), align='right')
        help_text = 'Use arrow keys to scroll the list and move to the' \
                ' buttons. Press "q" to quit.'
        footer = urwid.AttrWrap(
            urwid.Columns([urwid.Text(help_text), self.status]), 'footer')

        self.start = urwid.Text(('date', ''), align='right')
        self.end = urwid.Text(('date', datetime.date.today() \
                                       .strftime('  %d %B %Y  ')),
                              align='left')
        dates = urwid.Filler(
            urwid.Columns([
                self.start,
                urwid.Text(' to ', align='center'),
                self.end,
            ]), ('fixed top', 1))

        thead, tfoot = [], []
        self.total = {}
        for label in [
                'Booted at', 'Uptime', 'Received', 'Transmitted', 'Total'
        ]:
            thead.append(
                urwid.AttrWrap(urwid.Text(label, align='right'), 'thead'))
            self.total[label] = urwid.Text('', align='right')
            tfoot.append(urwid.AttrWrap(self.total[label], 'tfoot'))
        self.total['Booted at'].set_text('Total')
        thead = urwid.Filler(urwid.Columns(thead, 1, min_width=12))
        tfoot = urwid.Filler(urwid.Columns(tfoot, 1, min_width=12))

        self.tbody = urwid.ListBox([])
        qbutton = urwid.Filler(
            urwid.Columns(
                [
                    #            urwid.Padding(urwid.AttrWrap(urwid.Button('Settings',
                    #                                                      self.settings_dialog),
                    #                                         'button normal', 'button select'),
                    #                          'right', 12),
                    urwid.Divider('~'),
                    urwid.Padding(
                        urwid.AttrWrap(urwid.Button('Quit', self.quit),
                                       'button normal', 'button select'),
                        'center', 8),
                    urwid.Divider('~')
                ],
                3))
        body = urwid.AttrMap(
            urwid.Pile([('fixed', 3, dates), ('fixed', 1, thead), self.tbody,
                        ('fixed', 1, tfoot), ('fixed', 3, qbutton)]), 'bg')
        super(MainView, self).__init__(body=body, header=header, footer=footer)

        for settings in Settings.select():
            self.settings = settings
            break
        else:
            now = datetime.datetime.now()
            start = datetime.datetime(year=now.year, month=now.month, day=1)
            self.settings = Settings(start=start)

        self.populate()