From 8af06af1cf3b3d4e554b67f6ef64c68219166fbf Mon Sep 17 00:00:00 2001 From: Adrien Tétar Date: Tue, 6 Oct 2015 14:02:34 +0200 Subject: meta: CurrentGlyph() support, drop dead code, nits --- Lib/defconQt/scriptingWindow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Lib/defconQt/scriptingWindow.py') diff --git a/Lib/defconQt/scriptingWindow.py b/Lib/defconQt/scriptingWindow.py index eef90e3..f48fd0a 100644 --- a/Lib/defconQt/scriptingWindow.py +++ b/Lib/defconQt/scriptingWindow.py @@ -8,7 +8,6 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QMenu, QPlainTextEdit class MainScriptingWindow(QMainWindow): def __init__(self): super(MainScriptingWindow, self).__init__() - self.setAttribute(Qt.WA_DeleteOnClose) self.editor = PythonEditor(parent=self) self.resize(600, 500) @@ -31,6 +30,7 @@ class MainScriptingWindow(QMainWindow): "__builtins__": __builtins__, "AllFonts": app.allFonts, "CurrentFont": app.currentFont, + "CurrentGlyph": app.currentGlyph, } try: code = compile(script, "", "exec") @@ -57,9 +57,11 @@ class PythonEditor(CodeEditor): if key in self.autocomplete.keys(): super(PythonEditor, self).keyPressEvent(event) cursor = self.textCursor() - cursor.insertText(self.autocomplete[key][-1]) - cursor.movePosition(QTextCursor.PreviousCharacter) - self.setTextCursor(cursor) + ok = cursor.movePosition(QTextCursor.NextCharacter) + if not ok: + cursor.insertText(self.autocomplete[key][-1]) + cursor.movePosition(QTextCursor.PreviousCharacter) + self.setTextCursor(cursor) event.accept() return elif key == Qt.Key_Backspace: -- cgit v1.2.3