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