コード例 #1
0
    def generate_display_widget(self, size):
        """
        Actually generate display widget (ignoring cache)
        """
        (maxcol,) = size
        d = Divider()
        if len(self.cells) == 0: # how dull
            return d

        if self.v_sep > 1:
            # increase size of divider
            d.top = self.v_sep-1

        # cells per row
        bpr = (maxcol+self.h_sep) // (self.cell_width+self.h_sep)

        if bpr == 0: # too narrow, pile them on top of eachother
            l = [self.cells[0]]
            f = 0
            for b in self.cells[1:]:
                if b is self.focus_cell:
                    f = len(l)
                if self.v_sep:
                    l.append(d)
                l.append(b)
            return Pile(l, f)
        
        if bpr >= len(self.cells): # all fit on one row
            k = len(self.cells)
            f = self.cells.index(self.focus_cell)
            cols = Columns(self.cells, self.h_sep, f)
            rwidth = (self.cell_width+self.h_sep)*k - self.h_sep
            row = Padding(cols, self.align, rwidth)
            return row

        
        out = []
        s = 0
        f = 0
        while s < len(self.cells):
            if out and self.v_sep:
                out.append(d)
            k = min( len(self.cells), s+bpr )
            cells = self.cells[s:k]
            if self.focus_cell in cells:
                f = len(out)
                fcol = cells.index(self.focus_cell)
                cols = Columns(cells, self.h_sep, fcol)
            else:
                cols = Columns(cells, self.h_sep)
            rwidth = (self.cell_width+self.h_sep)*(k-s)-self.h_sep
            row = Padding(cols, self.align, rwidth)
            out.append(row)
            s += bpr
        return Pile(out, f)    
コード例 #2
0
ファイル: osk.py プロジェクト: xovox/RetroPie-Setup
    def setup_popup(self, title):
        """
        Overlays a dialog box on top of the working view using a Frame
        """

        # Header
        if self.small_display:
            header = Padding(Text(title, align='center'))
        else:
            header = LineBox(Text(title),
                             tline=None,
                             rline=' ',
                             lline=' ',
                             trcorner=' ',
                             tlcorner=' ',
                             blcorner='',
                             brcorner='')

        header = AttrWrap(header, 'header')

        # Body
        error_text = Text("", align='center')
        # register the Text widget with the application, so we can change it
        self._error = error_text

        error_text = AttrWrap(error_text, 'error')
        body = Pile([
            Divider(), error_text,
            Divider(),
            LineBox(GridFlow([self.setup_button("Dismiss", self.close_popup)],
                             12, 2, 0, 'center'),
                    bline=None,
                    lline=None,
                    rline=None,
                    tlcorner='─',
                    trcorner='─')
        ])

        body = LineBox(body)
        body = AttrWrap(body, 'body')

        # on small displays let the popup fill the screen (horizontal)
        if self.small_display:
            body = Padding(Filler(body, 'middle'), 'center')
        else:
            body = Padding(Filler(body, 'middle'), 'center', ('relative', 50))

        body = AttrWrap(body, 'bg')

        # Main dialog widget
        dialog = Frame(body, header=header, focus_part='body')

        return dialog
コード例 #3
0
ファイル: console.py プロジェクト: davidli2017/taurus
 def __init__(self):
     self.data = DataPoint(0)
     self.percentiles = PercentilesList(DataPoint.CURRENT)
     self.avg_times = AvgTimesList(DataPoint.CURRENT)
     self.rcodes = RCodesList(DataPoint.CURRENT)
     original_widget = Columns(
         [self.avg_times, self.percentiles, self.rcodes], dividechars=1)
     padded = Padding(original_widget, align=CENTER)
     super(LatestStats, self).__init__(padded, self.title)
コード例 #4
0
 def __init__(self):
     self.data = DataPoint(0)
     self.percentiles = PercentilesList(DataPoint.CUMULATIVE)
     self.avg_times = AvgTimesList(DataPoint.CUMULATIVE)
     self.rcodes = RCodesList(DataPoint.CUMULATIVE)
     original_widget = Columns(
         [self.avg_times, self.percentiles, self.rcodes], dividechars=1)
     padded = Padding(original_widget, align=CENTER)
     super(CumulativeStats, self).__init__(padded, "Cumulative Stats")
コード例 #5
0
ファイル: console.py プロジェクト: arthurlogilab/taurus
    def __init__(self):
        self.idx = 0
        b_txt = BigText("Taurus", Thin6x6Font())
        b_txt = Padding(b_txt, CENTER, width=CLIP)
        b_txt = Filler(b_txt)

        self.byb = Filler(Text('', align=CENTER))
        parts = [
            (5, b_txt),
            (1, self.byb),
        ]
        super(TaurusLogo, self).__init__(parts)
コード例 #6
0
 def __init__(self):
     self.data = DataPoint(0)
     self._start_time = None
     self.percentiles = PercentilesList(DataPoint.CUMULATIVE)
     self.avg_times = AvgTimesList(DataPoint.CUMULATIVE)
     self.rcodes = RCodesList(DataPoint.CUMULATIVE)
     self.labels_pile = LabelsPile(DataPoint.CUMULATIVE)
     original_widget = Pile([
         Columns([self.avg_times, self.percentiles, self.rcodes],
                 dividechars=1), self.labels_pile
     ])
     padded = Padding(original_widget, align=CENTER)
     super(CumulativeStats,
           self).__init__(padded, self.title + ': waiting for data...')
コード例 #7
0
ファイル: osk.py プロジェクト: xovox/RetroPie-Setup
    def setup_frame(self, title, input_title):
        """
        Creates the main view, with a 3 horizontal pane container (Frame)
        """
        self.keys = []  # List of keys added to the OSK
        self._shift = False  # OSK Shift key state

        # title frame (header) uses a LineBox with just the bottom line enabled
        # if we're on a small display, use a simple Text with Padding
        if self.small_display:
            header = Padding(Text(title, align='center'))

        else:
            header = LineBox(Text(title),
                             tline=None,
                             rline=' ',
                             lline=' ',
                             trcorner=' ',
                             tlcorner=' ',
                             blcorner='',
                             brcorner='')

        header = AttrWrap(header, 'header')

        # Body frame, containing the input and the OSK widget
        input = Text([('input text', ''), ('prompt', ASCII_BLOCK)])
        self.input = input

        Key = self.add_osk_key  # alias the key creation function
        osk = Pile([
            # 1st keyboard row
            WrappableColumns([
                (1, Text(" ")),
                (3, Key('`', shifted='~')),
                (3, Key('1', shifted='!')),
                (3, Key('2', shifted='@')),
                (3, Key('3', shifted='#')),
                (3, Key('4', shifted='$')),
                (3, Key('5', shifted='%')),
                (3, Key('6', shifted='^')),
                (3, Key('7', shifted='&')),
                (3, Key('8', shifted='*')),
                (3, Key('9', shifted='(')),
                (3, Key('0', shifted=')')),
                (3, Key('-', shifted='_')),
                (3, Key('=', shifted='+')),
                (1, Text(" ")),
            ], 0),
            Divider(),
            # 2nd keyboard row
            WrappableColumns([
                (2, Text(" ")),
                (3, Key('q')),
                (3, Key('w')),
                (3, Key('e')),
                (3, Key('r')),
                (3, Key('t')),
                (3, Key('y')),
                (3, Key('u')),
                (3, Key('i')),
                (3, Key('o')),
                (3, Key('p')),
                (3, Key('[', shifted='{')),
                (3, Key(']', shifted='}')),
                (3, Key('\\', shifted='|')),
            ], 0),
            Divider(),
            # 3rd keyboard row
            WrappableColumns([
                (3, Text(" ")),
                (3, Key('a')),
                (3, Key('s')),
                (3, Key('d')),
                (3, Key('f')),
                (3, Key('g')),
                (3, Key('h')),
                (3, Key('j')),
                (3, Key('k')),
                (3, Key('l')),
                (3, Key(';', shifted=':')),
                (3, Key('\'', shifted='"')),
            ], 0),
            Divider(),
            # 4th keyboard row
            WrappableColumns([(4, Text(" ")), (3, Key('z')), (3, Key('x')),
                              (3, Key('c')), (3, Key('v')), (3, Key('b')),
                              (3, Key('n')), (3, Key('m')),
                              (3, Key(',', shifted='<')),
                              (3, Key('.', shifted='>')),
                              (3, Key('/', shifted='?'))], 0),
            Divider(),
            # 5th (last) keyboard row
            WrappableColumns([
                (1, Text(" ")),
                (9,
                 Key('↑ Shift',
                     shifted='↑ SHIFT',
                     callback=self.shift_key_press)),
                (2, Text(" ")),
                (15, Key('Space', value=' ', shifted=' ')),
                (2, Text(" ")),
                (10, Key('Delete ←', callback=self.bksp_key_press)),
            ], 0),
            Divider()
        ])

        if self.small_display:
            # small displays: remove last divider line
            osk.contents.pop(len(osk.contents) - 1)

        osk = Padding(osk, 'center', 40)

        # setup the text input and the buttons
        input = AttrWrap(LineBox(input), 'input')
        input = Padding(AttrWrap(input, 'input text'),
                        'center', ('relative', 80),
                        min_width=30)
        ok_btn = self.setup_button("OK", self.button_press, exitcode=0)
        cancel_btn = self.setup_button("Cancel", self.button_press, exitcode=1)

        # setup the main OSK area, depending on the screen size
        if self.small_display:
            body = Pile([
                Text(f'Enter the {input_title}', align='center'), input,
                Divider(), osk,
                Divider(),
                GridFlow([ok_btn, cancel_btn], 10, 2, 0, 'center'),
                Divider()
            ])
        else:
            body = Pile([
                Divider(), input,
                Divider(), osk,
                LineBox(GridFlow([ok_btn, cancel_btn], 10, 2, 0, 'center'),
                        bline=None,
                        lline=None,
                        rline=None,
                        tlcorner='─',
                        trcorner='─')
            ])
            body = LineBox(body, f'Enter the {input_title}')

        body = AttrWrap(body, 'body')  # Style the main OSK area

        # wrap and align the main OSK in the frame
        body = Padding(body, 'center', 55, min_width=42)
        body = Filler(body, 'middle')

        body = AttrWrap(body, 'bg')  # Style the body containing the OSK

        frame = Frame(body, header=header, focus_part='body')

        return frame