示例#1
0
文件: widget.py 项目: dlobue/urwid
    def set_text(self,markup):
        """
        Set content of text widget.

        markup -- see __init__() for description.

        >>> t = Text("foo")
        >>> t.text
        'foo'
        >>> t.set_text("bar")
        >>> t.text
        'bar'
        >>> t.text = "baz"  # not supported because text stores text but set_text() takes markup
        Traceback (most recent call last):
            ...  
        AttributeError: can't set attribute
        """
        self._text, self._attrib = decompose_tagmarkup(markup)
        self._invalidate()
示例#2
0
文件: widget.py 项目: dlobue/urwid
    def set_caption(self, caption):
        """
        Set the caption markup for this widget.

        caption -- see Text.__init__() for description of markup
        
        >>> e = Edit("")
        >>> e.set_caption("cap1")
        >>> e.caption
        'cap1'
        >>> e.set_caption(('bold', "cap2"))
        >>> e.caption
        'cap2'
        >>> e.attrib
        [('bold', 4)]
        >>> e.caption = "cap3"  # not supported because caption stores text but set_caption() takes markup
        Traceback (most recent call last):
            ...  
        AttributeError: can't set attribute
        """
        self._caption, self._attrib = decompose_tagmarkup(caption)
        self._invalidate()
示例#3
0
文件: graphics.py 项目: dlobue/urwid
 def set_text(self, markup):
     self.text, self.attrib = decompose_tagmarkup(markup)
     self._invalidate()