How to use the stig.tui.views.CellWidgetBase function in stig

To help you get started, we’ve selected a few stig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rndusr / stig / stig / tui / views / file.py View on Github external
header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['name'].header),
                           style.attrs('header'))

    def get_mode(self):
        if self.data.nodetype == 'leaf':
            return 'file'
        else:
            return 'folder'

    def get_tui_value(self):
        return normalize_unicode(super().get_tui_value())

TUICOLUMNS['name'] = Filename


class Size(_COLUMNS['size'], CellWidgetBase):
    style = Style(prefix='filelist.size', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['size'].header),
                           style.attrs('header'))

TUICOLUMNS['size'] = Size


class Downloaded(_COLUMNS['downloaded'], CellWidgetBase):
    style = Style(prefix='filelist.downloaded', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['downloaded'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.data['%downloaded'] < 100 else None
github rndusr / stig / stig / tui / views / torrent.py View on Github external
TUICOLUMNS['downloaded'] = Downloaded


class PercentDownloaded(_COLUMNS['%downloaded'], CellWidgetBase):
    style = Style(prefix='torrentlist.%downloaded', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['%downloaded'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value < 100 else ''

TUICOLUMNS['%downloaded'] = PercentDownloaded


class Available(_COLUMNS['available'], CellWidgetBase):
    style = Style(prefix='torrentlist.available', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['available'].header),
                           style.attrs('header'))

    def get_mode(self):
        if self.value < self.data['size-final']:
            return 'highlighted'

TUICOLUMNS['available'] = Available


class PercentAvailable(_COLUMNS['%available'], CellWidgetBase):
    style = Style(prefix='torrentlist.%available', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['%available'].header),
github rndusr / stig / stig / tui / views / tracker.py View on Github external
header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['error-scrape'].header),
                           style.attrs('header'))

TUICOLUMNS['error-scrape'] = ErrorScrape


class Downloads(_COLUMNS['downloads'], CellWidgetBase):
    style = Style(prefix='trackerlist.downloads', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['downloads'].header),
                           style.attrs('header'))

TUICOLUMNS['downloads'] = Downloads


class Leeches(_COLUMNS['leeches'], CellWidgetBase):
    style = Style(prefix='trackerlist.leeches', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['leeches'].header),
                           style.attrs('header'))

TUICOLUMNS['leeches'] = Leeches


class Seeds(_COLUMNS['seeds'], CellWidgetBase):
    style = Style(prefix='trackerlist.seeds', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['seeds'].header),
                           style.attrs('header'))

TUICOLUMNS['seeds'] = Seeds
github rndusr / stig / stig / tui / views / tracker.py View on Github external
style.attrs('header'))

TUICOLUMNS['error-announce'] = ErrorAnnounce


class ErrorScrape(_COLUMNS['error-scrape'], CellWidgetBase):
    width = ('weight', 100)
    style = Style(prefix='trackerlist.error-scrape', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['error-scrape'].header),
                           style.attrs('header'))

TUICOLUMNS['error-scrape'] = ErrorScrape


class Downloads(_COLUMNS['downloads'], CellWidgetBase):
    style = Style(prefix='trackerlist.downloads', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['downloads'].header),
                           style.attrs('header'))

TUICOLUMNS['downloads'] = Downloads


class Leeches(_COLUMNS['leeches'], CellWidgetBase):
    style = Style(prefix='trackerlist.leeches', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['leeches'].header),
                           style.attrs('header'))

TUICOLUMNS['leeches'] = Leeches
github rndusr / stig / stig / tui / views / torrent.py View on Github external
class Ratio(_COLUMNS['ratio'], CellWidgetBase):
    style = Style(prefix='torrentlist.ratio', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['ratio'].header),
                           style.attrs('header'))

    def get_mode(self):
        if 0 <= self.value < 1:
            return 'highlighted'

TUICOLUMNS['ratio'] = Ratio


class RateUp(_COLUMNS['rate-up'], CellWidgetBase):
    style = Style(prefix='torrentlist.rate-up', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['rate-up'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value > 0 else ''

TUICOLUMNS['rate-up'] = RateUp


class RateDown(_COLUMNS['rate-down'], CellWidgetBase):
    style = Style(prefix='torrentlist.rate-down', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['rate-down'].header),
                           style.attrs('header'))
github rndusr / stig / stig / tui / views / torrent.py View on Github external
TUICOLUMNS['limit-rate-up'] = LimitRateUp


class LimitRateDown(_COLUMNS['limit-rate-down'], CellWidgetBase):
    style = Style(prefix='torrentlist.limit-rate-down', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['limit-rate-down'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value < float('inf') else ''

TUICOLUMNS['limit-rate-down'] = LimitRateDown


class Tracker(_COLUMNS['tracker'], CellWidgetBase):
    style = Style(prefix='torrentlist.tracker', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['tracker'].header),
                           style.attrs('header'))

TUICOLUMNS['tracker'] = Tracker


class Eta(_COLUMNS['eta'], CellWidgetBase):
    style = Style(prefix='torrentlist.eta', focusable=True,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['eta'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if bool(self.value) else ''
github rndusr / stig / stig / tui / views / tracker.py View on Github external
from ...views.tracker import COLUMNS as _COLUMNS


TUICOLUMNS = {}

class Torrent(_COLUMNS['torrent'], CellWidgetBase):
    width = ('weight', 50)
    style = Style(prefix='trackerlist.torrent', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['torrent'].header),
                           style.attrs('header'))

TUICOLUMNS['torrent'] = Torrent


class Tier(_COLUMNS['tier'], CellWidgetBase):
    style = Style(prefix='trackerlist.tier', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['tier'].header),
                           style.attrs('header'))

TUICOLUMNS['tier'] = Tier


class Domain(_COLUMNS['domain'], CellWidgetBase):
    width = ('weight', 20)
    style = Style(prefix='trackerlist.domain', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['domain'].header),
                           style.attrs('header'))

TUICOLUMNS['domain'] = Domain
github rndusr / stig / stig / tui / views / peer.py View on Github external
# Set IP address initially
        super().update(data)

        # Lookup hostname once per instance
        from ...objects import localcfg
        if localcfg['reverse-dns']:
            def set_hostname(hostname):
                if self.text.text != hostname:
                    self.text.set_text(hostname)
            from ...client import rdns
            rdns.query(data['ip'], callback=set_hostname)

TUICOLUMNS['host'] = Host


class Port(_COLUMNS['port'], CellWidgetBase):
    style = Style(prefix='peerlist.port', focusable=False,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['port'].header),
                           style.attrs('header'))

TUICOLUMNS['port'] = Port


class PercentDownloaded(_COLUMNS['%downloaded'], CellWidgetBase):
    style = Style(prefix='peerlist.%downloaded', focusable=False,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['%downloaded'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value < 100 else None
github rndusr / stig / stig / tui / views / peer.py View on Github external
TUICOLUMNS['%downloaded'] = PercentDownloaded


class RateUp(_COLUMNS['rate-up'], CellWidgetBase):
    style = Style(prefix='peerlist.rate-up', focusable=False,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['rate-up'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value > 0 else None

TUICOLUMNS['rate-up'] = RateUp


class RateDown(_COLUMNS['rate-down'], CellWidgetBase):
    style = Style(prefix='peerlist.rate-down', focusable=False,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['rate-down'].header),
                           style.attrs('header'))

    def get_mode(self):
        return 'highlighted' if self.value > 0 else None

TUICOLUMNS['rate-down'] = RateDown


class ETA(_COLUMNS['eta'], CellWidgetBase):
    style = Style(prefix='peerlist.eta', focusable=False,
                  extras=('header',), modes=('highlighted',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['eta'].header),
                           style.attrs('header'))
github rndusr / stig / stig / tui / views / torrent.py View on Github external
completed_col = int(maxcol * progress / 100)  # Width of first part of progress bar
            name1 = name[:completed_col]
            name2 = name[completed_col:]
            attrs1 = self.style.attrs(mode+'.progress1', focused=focus)
            attrs2 = self.style.attrs(mode+'.progress2', focused=focus)
            self.text.set_text([(attrs1, name1),
                                (attrs2, name2)])
        return super().render(size, focus)

    def get_mode(self):
        return self.status[1]

TUICOLUMNS['name'] = Name


class Path(_COLUMNS['path'], CellWidgetBase):
    width = 20
    style = Style(prefix='torrentlist.path', focusable=True,
                  extras=('header',))
    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['path'].header),
                           style.attrs('header'))

TUICOLUMNS['path'] = Path


class Status(_COLUMNS['status'], CellWidgetBase):
    style = Style(prefix='torrentlist.status', focusable=True,
                  extras=('header',),
                  modes=('idle', 'downloading', 'uploading', 'connected', 'seeding',
                         'stopped', 'queued', 'isolated', 'verifying', 'discovering'))

    header = urwid.AttrMap(ColumnHeaderWidget(**_COLUMNS['status'].header),