Skip to content
Permalink
Browse files

[processing] improved script edit dialog

  • Loading branch information
volaya committed Sep 1, 2013
1 parent 99525c3 commit 1655f8efc79c4387f69acb2e7fe7ec724f9c72b8
Showing with 37 additions and 6 deletions.
  1. +37 −6 python/plugins/processing/script/EditScriptDialog.py
@@ -50,13 +50,10 @@ def setupUi(self):
self.resize(600,400)
self.setWindowTitle("Edit script")
layout = QVBoxLayout()
self.text = QtGui.QTextEdit()
self.text.setObjectName("text")
self.text.setEnabled(True)
self.text = ScriptEditorWidget(self.alg.script if self.alg is not None else "")
#self.text.setEnabled(True)
self.buttonBox = QtGui.QDialogButtonBox()
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
if self.alg != None:
self.text.setText(self.alg.script)
self.editHelpButton = QtGui.QPushButton()
self.editHelpButton.setText("Edit script help")
self.buttonBox.addButton(self.editHelpButton, QtGui.QDialogButtonBox.ActionRole)
@@ -95,7 +92,7 @@ def saveAlgorithm(self):
if self.filename:
if not self.filename.endswith(".py"):
self.filename += ".py"
text = str(self.text.toPlainText())
text = self.text.text()
if self.alg is not None:
self.alg.script = text
try:
@@ -122,3 +119,37 @@ def saveAlgorithm(self):
def cancelPressed(self):
#self.update = False
self.close()

from PyQt4.Qsci import QsciScintilla, QsciLexerPython

class ScriptEditorWidget(QsciScintilla):
ARROW_MARKER_NUM = 8

def __init__(self, text, parent=None):
super(ScriptEditorWidget, self).__init__(parent)

font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(10)
self.setFont(font)
self.setMarginsFont(font)

fontmetrics = QFontMetrics(font)
self.setMarginsFont(font)
self.setMarginWidth(0, fontmetrics.width("00000") + 6)
self.setMarginLineNumbers(0, True)
self.setMarginsBackgroundColor(QColor("#cccccc"))

self.setBraceMatching(QsciScintilla.SloppyBraceMatch)

self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#ffe4e4"))

lexer = QsciLexerPython()
lexer.setDefaultFont(font)
self.setLexer(lexer)
self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')

self.setText(text)

0 comments on commit 1655f8e

Please sign in to comment.
You can’t perform that action at this time.