简体   繁体   中英

Pyqt4: how to add Margins in Qscintilla properly

I want to make my margin look like this:-
保证金设计pyqt4

and i have made like this till now:-
用户按金设计

with the following code:-

self.setMarginType(1,Qsci.QsciScintilla.NumberMargin)
self.setMarginWidth(1,40)
self.setMarginsForegroundColor(QtGui.QColor(120, 128, 120))
self.setMarginLineNumbers(1,True)

Please tell is there any mistake in this code, and what code should be added to display markers or margin containing markers(like blue dots at right side of numbers.)

you should define the marker style before you use it. here is the code :

class SimplePythonEditor(QsciScintilla):
    CIRCLE_MARKER_NUM = 0
    ......
    def __init__(self, parent=None):
       super(SimplePythonEditor, self).__init__(parent)
       self.markerDefine(QsciScintilla.Circle,self.CIRCLE_MARKER_NUM)
       self.setMarkerBackgroundColor(QColor(66, 66, 255),self.CIRCLE_MARKER_NUM)
       ......

    def on_margin_clicked(self, nmargin, nline, modifiers):
        # Toggle marker for the line the margin was clicked on
        if self.markersAtLine(nline) != 0:
            self.markerDelete(nline, self.CIRCLE_MARKER_NUM)
        else:
            self.markerAdd(nline, self.CIRCLE_MARKER_NUM)

for more details, you can modify eli's demo. eli's qscintilla demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM