aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/scriptingWindow.py
diff options
context:
space:
mode:
authorDenis Jacquerye2015-10-19 10:24:34 +0100
committerDenis Jacquerye2015-10-19 10:30:56 +0100
commit63f83224f474c2c191e8cac3cb6bda8f2cb81b7d (patch)
tree16b7c79b713832b93683cca9bc87018c48a3a88e /Lib/defconQt/scriptingWindow.py
parent9ce52ed3a18616828daf475fc487fd69322bee0e (diff)
downloadtrufont-63f83224f474c2c191e8cac3cb6bda8f2cb81b7d.tar.bz2
Use PEP8 code style
Diffstat (limited to 'Lib/defconQt/scriptingWindow.py')
-rw-r--r--Lib/defconQt/scriptingWindow.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/defconQt/scriptingWindow.py b/Lib/defconQt/scriptingWindow.py
index 38f70ab..c6403e8 100644
--- a/Lib/defconQt/scriptingWindow.py
+++ b/Lib/defconQt/scriptingWindow.py
@@ -2,10 +2,13 @@ from defconQt.baseCodeEditor import CodeEditor, CodeHighlighter
from keyword import kwlist
import traceback
from PyQt5.QtCore import Qt
-from PyQt5.QtGui import QColor, QFont, QKeySequence, QTextCharFormat, QTextCursor
-from PyQt5.QtWidgets import QApplication, QMainWindow, QMenu, QPlainTextEdit
+from PyQt5.QtGui import (
+ QColor, QFont, QKeySequence, QTextCharFormat, QTextCursor)
+from PyQt5.QtWidgets import QApplication, QMainWindow, QMenu
+
class MainScriptingWindow(QMainWindow):
+
def __init__(self):
super(MainScriptingWindow, self).__init__()
@@ -39,6 +42,7 @@ class MainScriptingWindow(QMainWindow):
except:
print(traceback.format_exc())
+
class PythonEditor(CodeEditor):
autocomplete = {
Qt.Key_ParenLeft: "()",
@@ -69,21 +73,25 @@ class PythonEditor(CodeEditor):
cursor = self.textCursor()
ok = cursor.movePosition(QTextCursor.PreviousCharacter)
if ok:
- ok = cursor.movePosition(QTextCursor.NextCharacter, QTextCursor.KeepAnchor, 2)
+ ok = cursor.movePosition(
+ QTextCursor.NextCharacter, QTextCursor.KeepAnchor, 2)
if ok and cursor.selectedText() in self.autocomplete.values():
cursor.removeSelectedText()
event.accept()
return
super(PythonEditor, self).keyPressEvent(event)
+
class PythonHighlighter(CodeHighlighter):
+
def __init__(self, parent=None):
super(PythonHighlighter, self).__init__(parent)
keywordFormat = QTextCharFormat()
keywordFormat.setForeground(QColor(34, 34, 34))
keywordFormat.setFontWeight(QFont.Bold)
- self.highlightingRules.append(("\\b(%s)\\b" % ("|".join(kwlist)), keywordFormat))
+ self.highlightingRules.append(
+ ("\\b(%s)\\b" % ("|".join(kwlist)), keywordFormat))
singleLineCommentFormat = QTextCharFormat()
singleLineCommentFormat.setForeground(Qt.darkGray)
@@ -91,8 +99,10 @@ class PythonHighlighter(CodeHighlighter):
classOrFnNameFormat = QTextCharFormat()
classOrFnNameFormat.setForeground(QColor(96, 106, 161))
- self.highlightingRules.append(("(?<=\\bclass\\s|def\\s\\b)\\s*(\\w+)", classOrFnNameFormat))
+ self.highlightingRules.append(
+ ("(?<=\\bclass\\s|def\\s\\b)\\s*(\\w+)", classOrFnNameFormat))
quotationFormat = QTextCharFormat()
quotationFormat.setForeground(QColor(223, 17, 68))
- self.highlightingRules.append(("'.*'|[\"]{1,3}.*[\"]{1,3}", quotationFormat))
+ self.highlightingRules.append(
+ ("'.*'|[\"]{1,3}.*[\"]{1,3}", quotationFormat))