本文整理汇总了Python中urwid.canvas.CompositeCanvas.fill_attr方法的典型用法代码示例。如果您正苦于以下问题:Python CompositeCanvas.fill_attr方法的具体用法?Python CompositeCanvas.fill_attr怎么用?Python CompositeCanvas.fill_attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid.canvas.CompositeCanvas
的用法示例。
在下文中一共展示了CompositeCanvas.fill_attr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from urwid.canvas import CompositeCanvas [as 别名]
# 或者: from urwid.canvas.CompositeCanvas import fill_attr [as 别名]
def render(self, size, focus=False):
fixed_size(size) # complain if parameter is wrong
a = None
ai = ak = 0
o = []
rows = self.font.height
attrib = self.attrib+[(None,len(self.text))]
for ch in self.text:
if not ak:
a, ak = attrib[ai]
ai += 1
ak -= 1
width = self.font.char_width(ch)
if not width:
# ignore invalid characters
continue
c = self.font.render(ch)
if a is not None:
c = CompositeCanvas(c)
c.fill_attr(a)
o.append((c, None, False, width))
if o:
canv = CanvasJoin(o)
else:
canv = TextCanvas([""]*rows, maxcol=0,
check_width=False)
canv = CompositeCanvas(canv)
canv.set_depends([])
return canv