source: sasview/src/sas/qtgui/Utilities/ModelEditor.py @ 3b3b40b

ESS_GUIESS_GUI_DocsESS_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 3b3b40b was 3b3b40b, checked in by Piotr Rozyczko <rozyczko@…>, 5 years ago

Merging feature branches

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