コード例 #1
0
ファイル: widget.py プロジェクト: dlobue/urwid
 def render(self, size, focus=False):
     """
     Render the divider as a canvas and return it.
     
     >>> Divider().render((10,)).text 
     ['          ']
     >>> Divider('-', top=1).render((10,)).text
     ['          ', '----------']
     >>> Divider('x', bottom=2).render((5,)).text
     ['xxxxx', '     ', '     ']
     """
     (maxcol,) = size
     canv = SolidCanvas(self.div_char, maxcol, 1)
     canv = CompositeCanvas(canv)
     if self.top or self.bottom:
         canv.pad_trim_top_bottom(self.top, self.bottom)
     return canv
コード例 #2
0
ファイル: decoration.py プロジェクト: dlobue/urwid
    def render(self, size, focus=False):    
        left, right = self.padding_values(size, focus)
        
        maxcol = size[0]
        maxcol -= left+right

        if self._width_type == CLIP:
            canv = self._original_widget.render((), focus)
        else:
            canv = self._original_widget.render((maxcol,)+size[1:], focus)
        if canv.cols() == 0:
            canv = SolidCanvas(' ', size[0], canv.rows())
            canv = CompositeCanvas(canv)
            canv.set_depends([self._original_widget])
            return canv
        canv = CompositeCanvas(canv)
        canv.set_depends([self._original_widget])
        if left != 0 or right != 0:
            canv.pad_trim_left_right(left, right)

        return canv