from PyQt5.Qt import * from PyQt5.Qsci import QsciScintilla from pathlib import Path if __name__ == '__main__': app = QApplication([]) view = QsciScintilla() view.setText(Path(__file__).read_text()) # Multiselection view.SendScintilla(view.SCI_SETMULTIPLESELECTION, True) view.SendScintilla(view.SCI_SETMULTIPASTE, 1) view.SendScintilla(view.SCI_SETADDITIONALSELECTIONTYPING, True) # Main/Additional selection coloring SC_ALPHA_NOALPHA = 256 view.SendScintilla(view.SCI_SETSELFORE, 0) view.SendScintilla(view.SCI_SETSELBACK, 1, QColor("#0000F0")) view.SendScintilla(view.SCI_SETSELALPHA, SC_ALPHA_NOALPHA) view.SendScintilla(view.SCI_SETADDITIONALSELBACK, QColor("#00F000")) view.SendScintilla(view.SCI_SETADDITIONALSELALPHA, SC_ALPHA_NOALPHA) # Create some selections # The selection of this comment should be green color # The selection of this comment should be green color # The selection of this comment should be green color # The selection of this comment should be green color # The selection of this comment should be green color # The selection of this comment should be blue color, if not, this is a BUG!!! for i, v in enumerate([(838, 891), (896, 949), (954, 1007), (1012, 1065), (1070, 1123), (1128, 1206)]): if i == 0: view.SendScintilla(view.SCI_SETSELECTION, *v) else: view.SendScintilla(view.SCI_ADDSELECTION, *v) view.resize(800, 600) view.show() app.exec_()