本文整理汇总了Python中urwid.canvas.CompositeCanvas.cursor方法的典型用法代码示例。如果您正苦于以下问题:Python CompositeCanvas.cursor方法的具体用法?Python CompositeCanvas.cursor怎么用?Python CompositeCanvas.cursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urwid.canvas.CompositeCanvas
的用法示例。
在下文中一共展示了CompositeCanvas.cursor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from urwid.canvas import CompositeCanvas [as 别名]
# 或者: from urwid.canvas.CompositeCanvas import cursor [as 别名]
def render(self, size, focus=False):
"""
Render the text content of this widget with a cursor when
in focus.
>>> si = SelectableIcon(u"[!]")
>>> si
<SelectableIcon selectable flow widget '[!]'>
>>> si.render((4,), focus=True).cursor
(1, 0)
>>> si = SelectableIcon("((*))", 2)
>>> si.render((8,), focus=True).cursor
(2, 0)
>>> si.render((2,), focus=True).cursor
(0, 1)
"""
c = self.__super.render(size, focus)
if focus:
# create a new canvas so we can add a cursor
c = CompositeCanvas(c)
c.cursor = self.get_cursor_coords(size)
return c
示例2: render
# 需要导入模块: from urwid.canvas import CompositeCanvas [as 别名]
# 或者: from urwid.canvas.CompositeCanvas import cursor [as 别名]
def render(self, size, focus=False):
"""
Render edit widget and return canvas. Include cursor when in
focus.
>>> c = Edit("? ","yes").render((10,), focus=True)
>>> c.text # ... = b in Python 3
[...'? yes ']
>>> c.cursor
(5, 0)
"""
(maxcol,) = size
self._shift_view_to_cursor = bool(focus)
canv = Text.render(self,(maxcol,))
if focus:
canv = CompositeCanvas(canv)
canv.cursor = self.get_cursor_coords((maxcol,))
# .. will need to FIXME if I want highlight to work again
#if self.highlight:
# hstart, hstop = self.highlight_coords()
# d.coords['highlight'] = [ hstart, hstop ]
return canv