考虑一下这个片段:
import sys
from PyQt5.Qsci import QsciScintilla
from PyQt5.Qt import *
if __name__ == '__main__':
app = QApplication(sys.argv)
view = QsciScintilla()
# http://www.scintilla.org/ScintillaDoc.html#Folding
view.setFolding(QsciScintilla.BoxedTreeFoldStyle)
# view.setFolding(QsciScintilla.BoxedFoldStyle)
# view.setFolding(QsciScintilla.CircledFoldStyle)
# view.setFolding(QsciScintilla.CircledTreeFoldStyle)
# view.setFolding(QsciScintilla.NoFoldStyle)
# view.setFolding(QsciScintilla.PlainFoldStyle)
lines = [
(0, "def foo():"),
(1, " x = 10"),
(1, " y = 20"),
(1, " return x+y"),
(-1, ""),
(0, "def bar(x):"),
(1, " if x > 0:"),
(2, " print('this is')"),
(2, " print('branch1')"),
(1, " else:"),
(2, " print('and this')"),
(2, " print('is branch2')"),
(-1, ""),
(-1, ""),
(-1, ""),
(-1, "print('end')"),
]
view.setText("\n".join([b for a, b in lines]))
MASK = QsciScintilla.SC_FOLDLEVELNUMBERMASK
for i, tpl in enumerate(lines):
level, line = tpl
if level >= 0:
view.SendScintilla(view.SCI_SETFOLDLEVEL, i, level | QsciScintilla.SC_FOLDLEVELHEADERFLAG)
else:
view.SendScintilla(view.SCI_SETFOLDLEVEL, i, 0)
view.show()
app.exec_()
我想弄清楚是否可以将折叠图标更改为与QScintilla提供的图标不同的自定义图标,特别是我希望有一个类似于Sublime的向下箭头:
通过观察qscisintilla foldstyle,你可以看到没有任何东西保持类似。在
事实上,不仅如此,我还想知道,当鼠标位置进入/离开边距区域时,是否有可能实现这种微妙的效果,使折叠图标消失,看看:
这是一个非常好的功能,这样当你编写代码时,你就不会被“总是可见”的折叠图标分心。在
在这个thread中似乎有一个叫做SC_MARK_ARROWDOWN
的东西,但不确定它是否可以作为折叠图标使用。。。无论如何,我还是喜欢我的定制图片,因为我将使用monokai主题,我希望图标看起来像崇高的优雅
下面你会看到我创建的2个12x12 png来表示暗光箭头。在
缺少悬停标记突出显示的初步版本:
相关问题 更多 >
编程相关推荐