mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
[processing] improved script edit dialog
This commit is contained in:
parent
99525c3c0f
commit
1655f8efc7
@ -50,13 +50,10 @@ class EditScriptDialog(QtGui.QDialog):
|
||||
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 @@ class EditScriptDialog(QtGui.QDialog):
|
||||
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 @@ class EditScriptDialog(QtGui.QDialog):
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user