Hello! On Tue, Feb 3, 2009 at 6:00 PM, Edward K. Ream <[email protected]> wrote: > > > On Tue, Feb 3, 2009 at 9:29 AM, Henning Schröder > <[email protected]> wrote: > >> I successfully implemented parenthesis matching with >> QTextEdit.ExtraSelection. > > Oh joy. > > Perhaps you could give me another hint. I'm confused by the docs at > http://doc.trolltech.com/4.4/qtextedit.html > > I don't understand how to specify selection and text format for > ExtraSelection elements: the ExtraSelection class seems to have neither ctor > nor settors.
I do something like that: tc = my_textedit.textCursor() tc.setPosition(start_pos) tc.setPosition(end_pos, QTextCursor.KeepAnchor) sel = QTextEdit.ExtraSelection() sel.cursor = tc se.format.setForeground(QColor.red) sel_list.append(sel) # keep the references my_textedit.setExtraSelections(sel_list) You can connect cursorPositionChanged() to a method which checks if the current char is a bracket. Then you create an extra selection. Either you remove the extra selection from your extra selection list if the position changed again or you use QTimer.singleShot The above code is not tested. If it does not work I can upload my editor widget code. Greets Henning _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
