def __init__(self, original_widget): """Draw a line around original_widget.""" tlcorner=None; tline=None; lline=None trcorner=None; blcorner=None; rline=None bline=None; brcorner=None def use_attr( a, t ): if a is not None: t = AttrWrap(t, a) return t tline = use_attr( tline, Divider(utf8decode("─"))) bline = use_attr( bline, Divider(utf8decode("─"))) lline = use_attr( lline, SolidFill(utf8decode("│"))) rline = use_attr( rline, SolidFill(utf8decode("│"))) tlcorner = use_attr( tlcorner, Text(utf8decode("┌"))) trcorner = use_attr( trcorner, Text(utf8decode("┐"))) blcorner = use_attr( blcorner, Text(utf8decode("└"))) brcorner = use_attr( brcorner, Text(utf8decode("┘"))) top = Columns([ ('fixed', 1, tlcorner), tline, ('fixed', 1, trcorner) ]) middle = Columns( [('fixed', 1, lline), original_widget, ('fixed', 1, rline)], box_columns = [0,2], focus_column = 1) bottom = Columns([ ('fixed', 1, blcorner), bline, ('fixed', 1, brcorner) ]) pile = Pile([('flow',top),middle,('flow',bottom)], focus_item = 1) WidgetDecoration.__init__(self, original_widget) WidgetWrap.__init__(self, pile)
def __init__(self, original_widget, title=None, title_attr=None, attr=None):#{{{ self.title = title self.title_attr = title_attr self.attr = attr self._attr = attr def _get_attr(w): if attr is not None: return AttrMap(w, attr) return w self.tline = _get_attr(Divider(utf8decode("─"))) self.bline = _get_attr(Divider(utf8decode("─"))) self.lline = _get_attr(SolidFill(utf8decode("│"))) self.rline = _get_attr(SolidFill(utf8decode("│"))) self.tlcorner = _get_attr(Text(utf8decode("┌"))) self.trcorner = _get_attr(Text(utf8decode("┐"))) self.blcorner = _get_attr(Text(utf8decode("└"))) self.brcorner = _get_attr(Text(utf8decode("┘"))) self._title_text = Text(" %s " % self.title, 'center') self._title = AttrMap(self._title_text, self.title_attr) top = Columns([('fixed', 1, self.tlcorner), self.tline, ('fixed', len(self.title)+2, self._title), self.tline, ('fixed', 1, self.trcorner)]) middle = Columns([('fixed', 1, self.lline), original_widget, ('fixed', 1, self.rline)], box_columns=[0,2], focus_column=1) bottom = Columns([('fixed', 1, self.blcorner), self.bline, ('fixed', 1, self.brcorner)]) pile = Pile([('flow', top), middle, ('flow', bottom)], focus_item=1) WidgetDecoration.__init__(self, original_widget) WidgetWrap.__init__(self, pile)