コード例 #1
0
    def __init__(self):
        super().__init__('default')

        # override existing formats
        function_format = QTextCharFormat()
        function_format.setForeground(self._get_brush("0000ff"))
        self.formats['function'] = function_format
コード例 #2
0
 def fmt() -> QTextCharFormat:
     """
     Get text char formatting for this object
     """
     fmt = QTextCharFormat()
     fmt.setForeground(Conf.disasm_view_node_mnemonic_color)
     return fmt
コード例 #3
0
    def foo(self):
        fmt = QTextCharFormat()
        fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)

        cursor = self.textEdit.textCursor()
        cursor.insertText(py3k.unichr(0xfffc), fmt)
        self.textEdit.setTextCursor(cursor)
        self.textEdit.close()
コード例 #4
0
    def clear_highlight(self):
        fmt = QTextCharFormat()
        fmt.setFont('Courier New')

        cur = self.box.textCursor()
        cur.select(QTextCursor.Document)
        cur.setCharFormat(fmt)
        self.box.setTextCursor(cur)
コード例 #5
0
    def foo(self):
        fmt = QTextCharFormat()
        fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType)

        cursor = self.textEdit.textCursor()
        cursor.insertText(py3k.unichr(0xfffc), fmt)
        self.textEdit.setTextCursor(cursor)
        self.textEdit.close()
コード例 #6
0
ファイル: sn_toolbars.py プロジェクト: JasonReek/SmartNotes
    def changeFontSize(self):
        font_format = QTextCharFormat()
        font_size = int(self._font_sizes.currentText())
        font_format.setFontPointSize(font_size)
        cursor = self._parent.activeNotepad().textCursor()
        cursor.mergeBlockCharFormat(font_format)

        self._parent.activeNotepad().setTextCursor(cursor)
        self._parent.activeNotepad().setFontPointSize(font_size)
コード例 #7
0
 def __init__(self, document):
     super().__init__(document)
     self.error_line = None
     self.command_format = QTextCharFormat()
     self.command_format.setForeground(QtCore.Qt.darkMagenta)
     self.error_format = QTextCharFormat()
     self.error_format.setUnderlineColor(QtCore.Qt.darkRed)
     self.error_format.setUnderlineStyle(
         QtGui.QTextCharFormat.SpellCheckUnderline)
     self.error_format.setBackground(QtCore.Qt.red)
コード例 #8
0
ファイル: highlighter.py プロジェクト: vkrm1612/robocomp
class Highlighter(QSyntaxHighlighter):
    def __init__(self, parent=None):
        super(Highlighter, self).__init__(parent)

        keywordFormat = QTextCharFormat()
        keywordFormat.setForeground(Qt.darkBlue)
        keywordFormat.setFontWeight(QFont.Bold)

        keywordPatterns = [
            "\\bimport\\b", "\\bcomponent\\b", "\\bcommunications\\b",
            "\\bpublishes\\b", "\\bimplements\\b", "\\bsubscribesTo\\b",
            "\\brequires\\b", "\\blanguage\\b", "\\bgui\\b", "\\boptions\\b",
            "\\binnermodelviewer\\b", "\\bstateMachine\\b", "\\bmodules\\b",
            "\\bagmagent\\b"
        ]

        self.highlightingRules = [(QRegExp(pattern), keywordFormat)
                                  for pattern in keywordPatterns]

        self.multiLineCommentFormat = QTextCharFormat()
        self.multiLineCommentFormat.setForeground(Qt.red)

        self.commentStartExpression = QRegExp("/\\*")
        self.commentEndExpression = QRegExp("\\*/")

    def highlightBlock(self, text):
        for pattern, format in self.highlightingRules:
            expression = QRegExp(pattern)
            index = expression.indexIn(text)
            while index >= 0:
                length = expression.matchedLength()
                self.setFormat(index, length, format)
                index = expression.indexIn(text, index + length)

        self.setCurrentBlockState(0)

        startIndex = 0
        if self.previousBlockState() != 1:
            startIndex = self.commentStartExpression.indexIn(text)

        while startIndex >= 0:
            endIndex = self.commentEndExpression.indexIn(text, startIndex)

            if endIndex == -1:
                self.setCurrentBlockState(1)
                commentLength = len(text) - startIndex
            else:
                commentLength = endIndex - startIndex + self.commentEndExpression.matchedLength(
                )

            self.setFormat(startIndex, commentLength,
                           self.multiLineCommentFormat)
            startIndex = self.commentStartExpression.indexIn(
                text, startIndex + commentLength)
コード例 #9
0
ファイル: py_highlighter.py プロジェクト: tws0002/Cirrus
def format(color, style=''):
    """Return a QTextCharFormat with the given attributes.
    """
    _color = QColor(color[0], color[1], color[2])

    _format = QTextCharFormat()
    _format.setFontFamily("Courier New")
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #10
0
ファイル: MainConsole.py プロジェクト: jbulow/Ryven
    def __init__(
            self,
            context=locals(),       # context for interpreter
            history: int = 100,     # max lines in history buffer
            blockcount: int = 5000  # max lines in output buffer
    ):

        super(MainConsole, self).__init__()

        # CREATE UI

        self.content_layout = QGridLayout(self)
        self.content_layout.setContentsMargins(0, 0, 0, 0)
        self.content_layout.setSpacing(0)

        # reset scope button
        self.reset_scope_button = QPushButton('reset console scope')
        self.reset_scope_button.clicked.connect(self.reset_scope_clicked)
        self.content_layout.addWidget(self.reset_scope_button, 0, 0, 1, 2)
        self.reset_scope_button.hide()

        # display for output
        self.out_display = ConsoleDisplay(blockcount, self)
        self.content_layout.addWidget(self.out_display, 1, 0, 1, 2)

        # colors to differentiate input, output and stderr
        self.inpfmt = self.out_display.currentCharFormat()
        self.inpfmt.setForeground(QBrush(QColor('white')))
        self.outfmt = QTextCharFormat(self.inpfmt)
        self.outfmt.setForeground(QBrush(QColor('#A9D5EF')))
        self.errfmt = QTextCharFormat(self.inpfmt)
        self.errfmt.setForeground(QBrush(QColor('#B55730')))

        # display input prompt left besides input edit
        self.prompt_label = QLabel('> ', self)
        self.prompt_label.setFixedWidth(15)
        self.content_layout.addWidget(self.prompt_label, 2, 0)

        # command line
        self.inpedit = LineEdit(max_history=history)
        self.inpedit.returned.connect(self.push)
        self.content_layout.addWidget(self.inpedit, 2, 1)


        self.interp = None
        self.reset_interpreter()

        self.buffer = []
        self.num_added_object_contexts = 0
コード例 #11
0
    def clear_highlight(self):
        fmt = QTextCharFormat()
        fmt.setFont('Courier New')
        # clearing past highlights
        addr_cur = self.addresses.textCursor()  # getting cursors
        mem_cur = self.mem_display.textCursor()
        chr_cur = self.chr_display.textCursor()

        addr_cur.select(QTextCursor.Document)   # selecting entire document
        mem_cur.select(QTextCursor.Document)
        chr_cur.select(QTextCursor.Document)
        
        addr_cur.setCharFormat(fmt) # adding format
        mem_cur.setCharFormat(fmt)
        chr_cur.setCharFormat(fmt)
コード例 #12
0
def text_format(color, style=''):
    f = QTextCharFormat()
    f.setForeground(color)
    if 'bold' in style:
        f.setFontWeight(QFont.Bold)
    if 'italic' in style:
        f.setFontItalic(True)
    return f
コード例 #13
0
ファイル: text_view.py プロジェクト: deffi/noteeds
    def __init__(self, parent: Optional[QWidget]):
        super().__init__(parent)

        self.setTabChangesFocus(True)
        self.setReadOnly(False)
        self.setCenterOnScroll(True)

        self.verticalScrollBar().valueChanged.connect(self.highlight_visible)

        self._search_term = None

        self._text_format = QTextCharFormat()
        self._text_format.setFontWeight(QFont.Bold)
        self._text_format.setForeground(Qt.darkMagenta)
        self._text_format.setBackground(Qt.yellow)
コード例 #14
0
 def set_format(self, fmt: QtGui.QTextCharFormat):
     cur = self.textCursor()
     self.selectAll()
     self.setCurrentCharFormat(fmt)
     self.setTextCursor(cur)
     tab_stop = settings.tabstop
     self.setTabStopWidth(tab_stop * QtGui.QFontMetrics(fmt.font()).width(" "))
コード例 #15
0
ファイル: css_syntax.py プロジェクト: UN-GCPDS/bci-framework
    def get_format(cls, color: str, style='', fontsize=None) -> QTextCharFormat:
        """Return a QTextCharFormat with the given attributes."""
        _color = QColor()
        _color.setNamedColor(color)

        _format = QTextCharFormat()
        _format.setForeground(_color)
        if 'bold' in style:
            _format.setFontWeight(QFont.Bold)
        if 'italic' in style:
            _format.setFontItalic(True)

        if fontsize:
            _format.setFontPointSize(fontsize)

        return _format
コード例 #16
0
ファイル: bug_662.py プロジェクト: Daetalus/pyside2-setup
    def tesIterator(self):
        edit = QTextEdit()
        cursor = edit.textCursor()
        fmt = QTextCharFormat()
        frags = []
        for i in range(10):
            fmt.setFontPointSize(i + 10)
            frags.append("block%d" % i)
            cursor.insertText(frags[i], fmt)

        doc = edit.document()
        block = doc.begin()

        index = 0
        for i in block:
            self.assertEqual(i.fragment().text(), frags[index])
            index += 1
コード例 #17
0
ファイル: bug_662.py プロジェクト: BadSingleton/pyside2
    def tesIterator(self):
        edit = QTextEdit()
        cursor = edit.textCursor()
        fmt = QTextCharFormat()
        frags = []
        for i in range(10):
            fmt.setFontPointSize(i+10)
            frags.append("block%d"%i)
            cursor.insertText(frags[i], fmt)

        doc = edit.document()
        block = doc.begin()

        index = 0
        for i in block:
            self.assertEqual(i.fragment().text(), frags[index])
            index += 1
コード例 #18
0
 def _formatiraj(self, r, g, b, stil=''):
     #_boja = QColor()
     _boja = QColor.fromRgb(r, g, b, 255)
     _format = QTextCharFormat()
     _format.setForeground(_boja)
     if 'bold' in stil:
         _format.setFontWeight(QFont.Bold)
     if 'italic' in stil:
         _format.setFontItalic(True)
     return _format
コード例 #19
0
ファイル: syntaxhighlight.py プロジェクト: safu9/Momiji
    def __init__(self, document, **options):
        Formatter.__init__(self, **options)

        self.document = document

        # Prepare format by styles
        self.styles = {}
        for token, style in self.style:
            format = QTextCharFormat()
            if style['color']:
                format.setForeground(QColor('#' + style['color']))
            if style['bold']:
                format.setFontWeight(QFont.Bold)
            if style['italic']:
                format.setFontItalic(True)
            if style['underline']:
                format.setFontUnderline(True)
            self.styles[token] = format
コード例 #20
0
ファイル: python.py プロジェクト: Sugz/SugzEditor-PySide2
    def getTextCharFormat(self, color, style=None):
        """Return a QTextCharFormat with the given attributes."""
        textCharFormat = QTextCharFormat()
        textCharFormat.setForeground(color)
        if style is not None:
            if 'bold' in style:
                textCharFormat.setFontWeight(QFont.Bold)
            if 'italic' in style:
                textCharFormat.setFontItalic(True)

        return textCharFormat
コード例 #21
0
    def updateRules(self):
        try:
            keywordFormat = QTextCharFormat()
            keywordFormat.setForeground(QColor("#000099"))
            keywordFormat.setFontWeight(QFont.Bold)
            keywordFormat.setFontUnderline(True)
            keywordFormat.setAnchor(True)

            dict_words = self._database.getAllDictWords()
            keywordPatterns = ["\\b" + word + "\\b" for word in dict_words]
            keywordPatterns.extend(
                ["\\b" + word.upper() + "\\b" for word in dict_words])
            keywordPatterns.extend(
                ["\\b" + word.lower() + "\\b" for word in dict_words])
            self.highlightingRules = [(QRegExp(pattern), keywordFormat)
                                      for pattern in keywordPatterns]

        except Exception as e:
            print("Failed to update the highlighting rules:", e)
コード例 #22
0
def format(color, style=''):
    """Return a QTextCharFormat with the given attributes."""
    _color = eval('getThemeColor(ThemeColor.%s)' % color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #23
0
    def log(self, text, level=MessageType.INFO):
        if level is MessageType.INFO:
            color = "000000"
        elif level is MessageType.WARNING:
            color = "#9ece2f"
        elif level is MessageType.ERROR:
            color = "#ed2d2d"
        elif level is MessageType.SUCCESS:
            color = "#4dd30a"
        else:
            raise UndefinedMessageType(
                "Undefined message type: {type}.".format(type=level))

        line_format = QTextCharFormat()
        line_format.setForeground(QBrush(QColor(color)))
        self.text_cursor.setCharFormat(line_format)

        self.text_cursor.insertText(text + "\n")
        self.textbox.verticalScrollBar().setValue(
            self.textbox.verticalScrollBar().maximum())
コード例 #24
0
    def on_log_received(self, data):
        time_info = datetime.fromtimestamp((data['time'] / 1000)).isoformat()
        log_message = '%s: %s : %s' % (time_info, data['level'],
                                       data['message'])
        message_document = self.document()
        cursor_to_add = QTextCursor(message_document)
        cursor_to_add.movePosition(cursor_to_add.End)
        cursor_to_add.insertText(log_message + '\n')

        if data['level'] in COLORS:
            fmt = QTextCharFormat()
            fmt.setForeground(COLORS[data['level']])
            cursor_to_add.movePosition(cursor_to_add.PreviousBlock)
            log_lvl_data = LogLevelData(log_levels[data['level'].upper()])
            cursor_to_add.block().setUserData(log_lvl_data)
            cursor_to_add_fmt = message_document.find(data['level'],
                                                      cursor_to_add.position())
            cursor_to_add_fmt.mergeCharFormat(fmt)
            if log_levels[data['level']] > self.log_lvl:
                cursor_to_add.block().setVisible(False)
        self.ensureCursorVisible()
コード例 #25
0
 def __init__(self, dokument):
     super(CSyntax, self).__init__(dokument)
     self.rules = []
     self.formater = Formater()
     # self.rules += [(r'(\/\*[^(\*\/)]*\*\/)', 0, self.formater.stilovi['comment'])]
     self.rules += [(r'\b%s\b' % w, self.formater.stilovi['keyword']) for w in CSyntax.keywords_c]
     # self.rules += [(r'\b%s\b' % w, 0, self.formater.stilovi['declarations']) for w in CSyntax.functions]
     self.rules += [(QRegExp(r'\b(?!(?:if|switch|while|void|for)[\s*|(])\b[A-Za-z0-9\_]+\s*(?=\([^\)]*\)\s*)'),
                     self.formater.stilovi['declarations'])]
     self.rules += [(QRegExp(r'#[^\n]*'), self.formater.stilovi['string_c'])]
     self.rules += [(QRegExp(r"\".*\""), self.formater.stilovi['string'])]
     self.rules += [(QRegExp(r"\'.?\'"), self.formater.stilovi['string'])]
     # self.multiline_comment_start = r'/\*.*'
     # self.multiline_comment_end = r'[^\*/]*\*/'
     # self.multiline_comment_start = r'/\\*'
     # self.multiline_comment_end = r'\\*/'
     self.multiLineCommentFormat = QTextCharFormat()
     self.multiLineCommentFormat.setForeground(Qt.red)
     self.commentStartExpression = QRegExp("/\\*")
     self.commentEndExpression = QRegExp("\\*/")
     self.rules += [(QRegExp(r'//[^\n]*'), self.formater.stilovi['comment_c'])]
コード例 #26
0
def txformat(color, style=''):
    """Return a QTextCharFormat with the given attributes.
    """
    _color = QColor()
    _color.setNamedColor(color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #27
0
ファイル: panel2.py プロジェクト: Zamtos/Panel2
    def newLetter(self):
        self.textEdit.clear()

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)
        #        timer = QTimer(self)
        #        timer.timeout.connect(self.showTime)
        #        timer.start(1000)
        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("Tomasz Dróżdż", boldFormat)
        cursor.insertBlock()
        cursor.insertText("Politechnika Wrocławska", textFormat)
        cursor.insertBlock()
        cursor.insertText("Automatyka i Robotyka")
        cursor.insertBlock()
        cursor.insertText("SOLAR PANEL Program")
        cursor.setPosition(topFrame.lastPosition())
        cursor.insertText(
            QDate.currentDate().toString("Dziś jest: d MMMM yyyy:"),
            textFormat)
        cursor.insertText(QTime.currentTime().toString("  hh:mm:ss"),
                          textFormat)
        #        cursor.insertText(QTimer.timer("  hh:mm:ss", 1000), textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Wrocław: ", textFormat)
        cursor.insertText("17.03 deg; 51.10 deg", textFormat)
        cursor.insertText(",", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("Text", textFormat)
コード例 #28
0
    def highlight(self, addr):
        fmt = QTextCharFormat()
        fmt.setBackground(Qt.cyan)
        fmt.setFont('Courier New')

        cur = self.box.textCursor()

        text = self.box.toPlainText()
        count = 0
        for line in text.split('\n'):
            if len(line) > 0:
                line_addr = line.split()[0]
                n = (len(line_addr[2:-1]) * 4)
                mask = (2**n) - 1
                if int(line_addr[:-1], 16) == (addr & mask):
                    break
                count += 1
        block = self.box.document().findBlockByLineNumber(count)
        cur.setPosition(block.position())

        cur.select(QTextCursor.LineUnderCursor)

        cur.setCharFormat(fmt)

        self.box.setTextCursor(cur)
コード例 #29
0
    def newLetter(self):
        self.textEdit.clear()

        cursor = self.textEdit.textCursor()
        cursor.movePosition(QTextCursor.Start)
        topFrame = cursor.currentFrame()
        topFrameFormat = topFrame.frameFormat()
        topFrameFormat.setPadding(16)
        topFrame.setFrameFormat(topFrameFormat)

        textFormat = QTextCharFormat()
        boldFormat = QTextCharFormat()
        boldFormat.setFontWeight(QFont.Bold)
        italicFormat = QTextCharFormat()
        italicFormat.setFontItalic(True)

        tableFormat = QTextTableFormat()
        tableFormat.setBorder(1)
        tableFormat.setCellPadding(16)
        tableFormat.setAlignment(Qt.AlignRight)
        cursor.insertTable(1, 1, tableFormat)
        cursor.insertText("The Firm", boldFormat)
        cursor.insertBlock()
        cursor.insertText("321 City Street", textFormat)
        cursor.insertBlock()
        cursor.insertText("Industry Park")
        cursor.insertBlock()
        cursor.insertText("Some Country")
        cursor.setPosition(topFrame.lastPosition())
        cursor.insertText(QDate.currentDate().toString("d MMMM yyyy"),
                          textFormat)
        cursor.insertBlock()
        cursor.insertBlock()
        cursor.insertText("Dear ", textFormat)
        cursor.insertText("NAME", italicFormat)
        cursor.insertText(",", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("Yours sincerely,", textFormat)
        for i in range(3):
            cursor.insertBlock()
        cursor.insertText("The Boss", textFormat)
        cursor.insertBlock()
        cursor.insertText("ADDRESS", italicFormat)
コード例 #30
0
ファイル: gameui.py プロジェクト: Matrixchung/EDAutopilot
 def onReceiveLog(self, data: LogMsg):
     format = QTextCharFormat()
     format.setForeground(QBrush(QColor(data.color)))
     self.mainUI.logText.setCurrentCharFormat(format)
     self.mainUI.logText.appendPlainText(data.text)
     format.setForeground(QBrush(
         QColor('black')))  # restore to default color
     self.mainUI.logText.setCurrentCharFormat(format)
コード例 #31
0
ファイル: sub.py プロジェクト: kiwitreekor/namuplant
 def __init__(self):
     super().__init__()
     self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
     self.setColumnCount(4)
     self.horizontalHeader().setVisible(False)
     self.verticalHeader().setVisible(False)
     self.horizontalHeader().setStretchLastSection(True)
     self.horizontalHeader().setMinimumSectionSize(10)
     self.horizontalHeader().setSectionResizeMode(
         QHeaderView.ResizeToContents)
     self.verticalHeader().setSectionResizeMode(
         QHeaderView.ResizeToContents)
     # 컬러 세트
     color_sub = QColor()
     color_sub.setNamedColor('#ffaaaa')
     color_add = QColor()
     color_add.setNamedColor('#aaffaa')
     self.fmt_sub = QTextCharFormat()
     self.fmt_sub.setBackground(color_sub)
     self.fmt_add = QTextCharFormat()
     self.fmt_add.setBackground(color_add)
     self.a = ''
     self.b = ''
コード例 #32
0
ファイル: ui.py プロジェクト: ramesharun/caribou
    def highlightBlock(self, text):
        string_format = QTextCharFormat()
        string_format.setForeground(QColor('#E6DB74'))

        number_format = QTextCharFormat()
        number_format.setForeground(QColor('#AE81FF'))
        if len(text) == 0:
            return

        current = 0
        for tokentype, value in JsonLexer().get_tokens(text):
            if tokentype in Name or tokentype in String:
                self.setFormat(current, len(value), string_format)
            elif tokentype in Number or tokentype in Keyword:
                self.setFormat(current, len(value), number_format)
            current += len(value)
コード例 #33
0
ファイル: SyntaxHighlight.py プロジェクト: cmbant/CosmoMC
def txformat(color, style=''):
    """Return a QTextCharFormat with the given attributes.
    """
    _color = QColor()
    _color.setNamedColor(color)

    _format = QTextCharFormat()
    _format.setForeground(_color)
    if 'bold' in style:
        _format.setFontWeight(QFont.Bold)
    if 'italic' in style:
        _format.setFontItalic(True)

    return _format
コード例 #34
0
ファイル: bug_688.py プロジェクト: BadSingleton/pyside2
    def testCase(self):
        editor = QTextEdit()
        cursor = QTextCursor(editor.textCursor())
        cursor.movePosition(QTextCursor.Start)
   
        mainFrame = cursor.currentFrame()
        
        plainCharFormat = QTextCharFormat()
        boldCharFormat = QTextCharFormat()
        boldCharFormat.setFontWeight(QFont.Bold);
        cursor.insertText("""
                          Text documents are represented by the 
                          QTextDocument class, rather than by QString objects. 
                          Each QTextDocument object contains information about 
                          the document's internal representation, its structure, 
                          and keeps track of modifications to provide undo/redo 
                          facilities. This approach allows features such as the 
                          layout management to be delegated to specialized 
                          classes, but also provides a focus for the framework.""",
                          plainCharFormat)

        frameFormat = QTextFrameFormat()
        frameFormat.setMargin(32)
        frameFormat.setPadding(8)
        frameFormat.setBorder(4)
        cursor.insertFrame(frameFormat)

        cursor.insertText("""
                          Documents are either converted from external sources 
                          or created from scratch using Qt. The creation process 
                          can done by an editor widget, such as QTextEdit, or by 
                          explicit calls to the Scribe API.""",
                          boldCharFormat)

        cursor = mainFrame.lastCursorPosition()
        cursor.insertText("""
                          There are two complementary ways to visualize the 
                          contents of a document: as a linear buffer that is 
                          used by editors to modify the contents, and as an 
                          object hierarchy containing structural information 
                          that is useful to layout engines. In the hierarchical 
                          model, the objects generally correspond to visual 
                          elements such as frames, tables, and lists. At a lower 
                          level, these elements describe properties such as the 
                          style of text used and its alignment. The linear 
                          representation of the document is used for editing and 
                          manipulation of the document's contents.""",
                          plainCharFormat)

        
        frame = cursor.currentFrame()

        items = []

        #test iterator
        for i in frame:
            items.append(i)

        #test __iadd__
        b = frame.begin()
        i = 0
        while not b.atEnd():
            self.assertEqual(b, items[i])
            self.assert_(b.parentFrame(), items[i].parentFrame())
            b.__iadd__(1)
            i += 1

        #test __isub__
        b = frame.end()
        i = 0
        while i > 0:
            self.assertEqual(b, items[i])
            self.assert_(b.parentFrame(), items[i].parentFrame())
            b.__isub__(1)
            i -= 1