source: sasview/src/sas/qtgui/Utilities/ModelEditor.py @ 5a731c63

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 5a731c63 was 8b480d27, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Code cleanup and minor fixes

  • Property mode set to 100644
File size: 1.4 KB
Line 
1from PyQt5 import QtCore
2from PyQt5 import QtWidgets
3
4from sas.qtgui.Utilities.PythonSyntax import PythonHighlighter
5
6from sas.qtgui.Utilities.UI.ModelEditor import Ui_ModelEditor
7
8class ModelEditor(QtWidgets.QDialog, Ui_ModelEditor):
9    """
10    Class describing the "advanced" model editor.
11    This is a simple text browser allowing for editing python and
12    supporting simple highlighting.
13    """
14    modelModified = QtCore.pyqtSignal()
15    def __init__(self, parent=None):
16        super(ModelEditor, self).__init__(parent)
17        self.setupUi(self)
18
19        self.setupWidgets()
20
21        self.addSignals()
22
23    def setupWidgets(self):
24        """
25        Set up dialog widgets.
26        Here - just the highlighter connected to the text edit.
27        """
28        self.highlight = PythonHighlighter(self.txtEditor.document())
29
30    def addSignals(self):
31        """
32        Respond to signals in the widget
33        """
34        self.txtEditor.textChanged.connect(self.onEdit)
35
36    def onEdit(self):
37        """
38        Respond to changes in the text browser.
39        """
40        # We have edited the model - notify the parent.
41        if self.txtEditor.toPlainText() != "":
42            self.modelModified.emit()
43
44    def getModel(self):
45        """
46        Return the current model, as displayed in the window
47        """
48        model = {'text':self.txtEditor.toPlainText()}
49        model['filename'] = ""
50        return model
51
Note: See TracBrowser for help on using the repository browser.