Last change
on this file since 6138f73 was
26970b3,
checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago
|
Fix for Sphinx crashing on importing QSyntaxHighlighter
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | from PyQt5 import QtCore |
---|
2 | from PyQt5 import QtWidgets |
---|
3 | |
---|
4 | from sas.qtgui.Utilities.UI.ModelEditor import Ui_ModelEditor |
---|
5 | |
---|
6 | class ModelEditor(QtWidgets.QDialog, Ui_ModelEditor): |
---|
7 | """ |
---|
8 | Class describing the "advanced" model editor. |
---|
9 | This is a simple text browser allowing for editing python and |
---|
10 | supporting simple highlighting. |
---|
11 | """ |
---|
12 | modelModified = QtCore.pyqtSignal() |
---|
13 | def __init__(self, parent=None): |
---|
14 | super(ModelEditor, self).__init__(parent) |
---|
15 | self.setupUi(self) |
---|
16 | |
---|
17 | self.setupWidgets() |
---|
18 | |
---|
19 | self.addSignals() |
---|
20 | |
---|
21 | def setupWidgets(self): |
---|
22 | """ |
---|
23 | Set up dialog widgets. |
---|
24 | Here - just the highlighter connected to the text edit. |
---|
25 | """ |
---|
26 | # Weird import location - workaround for a bug in Sphinx choking on |
---|
27 | # importing QSyntaxHighlighter |
---|
28 | # DO NOT MOVE TO TOP |
---|
29 | from sas.qtgui.Utilities.PythonSyntax import PythonHighlighter |
---|
30 | self.highlight = PythonHighlighter(self.txtEditor.document()) |
---|
31 | |
---|
32 | def addSignals(self): |
---|
33 | """ |
---|
34 | Respond to signals in the widget |
---|
35 | """ |
---|
36 | self.txtEditor.textChanged.connect(self.onEdit) |
---|
37 | |
---|
38 | def onEdit(self): |
---|
39 | """ |
---|
40 | Respond to changes in the text browser. |
---|
41 | """ |
---|
42 | # We have edited the model - notify the parent. |
---|
43 | if self.txtEditor.toPlainText() != "": |
---|
44 | self.modelModified.emit() |
---|
45 | |
---|
46 | def getModel(self): |
---|
47 | """ |
---|
48 | Return the current model, as displayed in the window |
---|
49 | """ |
---|
50 | model = {'text':self.txtEditor.toPlainText()} |
---|
51 | model['filename'] = "" |
---|
52 | return model |
---|
53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.