diff --git a/src/sas/qtgui/Calculators/DataOperationUtilityPanel.py b/src/sas/qtgui/Calculators/DataOperationUtilityPanel.py index 013afcca28..e30fca394e 100644 --- a/src/sas/qtgui/Calculators/DataOperationUtilityPanel.py +++ b/src/sas/qtgui/Calculators/DataOperationUtilityPanel.py @@ -23,7 +23,7 @@ def __init__(self, parent=None): super(DataOperationUtilityPanel, self).__init__() self.setupUi(self) self.manager = parent - self.communicator = self.manager.communicator() + self.communicator = GuiUtils.communicator # To store input datafiles self.filenames = None diff --git a/src/sas/qtgui/Calculators/GenericScatteringCalculator.py b/src/sas/qtgui/Calculators/GenericScatteringCalculator.py index f99c2c527d..ccdd9d2db3 100644 --- a/src/sas/qtgui/Calculators/GenericScatteringCalculator.py +++ b/src/sas/qtgui/Calculators/GenericScatteringCalculator.py @@ -52,7 +52,7 @@ def __init__(self, parent=None): self.setFixedSize(self.minimumSizeHint()) self.manager = parent - self.communicator = self.manager.communicator() + self.communicator = GuiUtils.communicator self.model = sas_gen.GenSAS() self.omf_reader = sas_gen.OMFReader() self.sld_reader = sas_gen.SLDReader() @@ -1541,7 +1541,7 @@ def complete(self, input, update=None): model_str, model_path = gsc_model.generate_plugin(self.txtFileName.text(), self.data_to_plot, self.xValues, self.fQ, self.rGMass) TabbedModelEditor.writeFile(model_path, model_str) - self.manager.communicate.customModelDirectoryChanged.emit() + self.communicator.customModelDirectoryChanged.emit() # Notify the user msg = "Custom model " + str(model_path.absolute()) + " successfully created." diff --git a/src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py b/src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py index 01bdc54932..34f8a3f555 100644 --- a/src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py +++ b/src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py @@ -23,7 +23,7 @@ from sas.qtgui.Calculators.Shape2SAS.ViewerModel import ViewerModel from sas.qtgui.Perspectives.perspective import Perspective from sas.qtgui.Plotting.PlotterData import Data1D -from sas.qtgui.Utilities.GuiUtils import createModelItemWithPlot +from sas.qtgui.Utilities.GuiUtils import communicator, createModelItemWithPlot # Local SasView from sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor import TabbedModelEditor @@ -59,7 +59,7 @@ def __init__(self, parent=None): self.parent = parent self._manager = parent - self.communicator = self._manager.communicator() + self.communicator = communicator ############Building GUI############## ###create build model tab diff --git a/src/sas/qtgui/Calculators/UnitTesting/DataOperationUtilityTest.py b/src/sas/qtgui/Calculators/UnitTesting/DataOperationUtilityTest.py index 74aa21c1f6..639b66c2d2 100644 --- a/src/sas/qtgui/Calculators/UnitTesting/DataOperationUtilityTest.py +++ b/src/sas/qtgui/Calculators/UnitTesting/DataOperationUtilityTest.py @@ -7,7 +7,7 @@ from sas.qtgui.Calculators.DataOperationUtilityPanel import DataOperationUtilityPanel from sas.qtgui.MainWindow.DataState import DataState from sas.qtgui.Plotting.PlotterData import Data1D, Data2D -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator BG_COLOR_ERR = 'background-color: rgb(244, 170, 164);' @@ -18,7 +18,7 @@ def widget(self, qapp): """Create/Destroy the DataOperationUtilityPanel""" class dummy_manager: def communicator(widget): - return Communicate() + return communicator w = DataOperationUtilityPanel(dummy_manager()) diff --git a/src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py b/src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py index 11ba2d532e..133ac4073b 100644 --- a/src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py +++ b/src/sas/qtgui/Calculators/UnitTesting/GenericScatteringCalculatorTest.py @@ -12,7 +12,7 @@ from sas.qtgui.Calculators.GenericScatteringCalculator import GenericScatteringCalculator, Plotter3D from sas.qtgui.Plotting.PlotterBase import PlotHelper -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator from sas.sascalc.calculator import sas_gen @@ -24,7 +24,7 @@ def widget(self, qapp): """Create/Destroy the GenericScatteringCalculator""" class dummy_manager: def communicator(self): - return Communicate() + return communicator w = GenericScatteringCalculator(dummy_manager()) diff --git a/src/sas/qtgui/Calculators/UnitTesting/ResolutionCalculatorPanelTest.py b/src/sas/qtgui/Calculators/UnitTesting/ResolutionCalculatorPanelTest.py index 66f011e450..31541be9c0 100644 --- a/src/sas/qtgui/Calculators/UnitTesting/ResolutionCalculatorPanelTest.py +++ b/src/sas/qtgui/Calculators/UnitTesting/ResolutionCalculatorPanelTest.py @@ -12,7 +12,7 @@ from twisted.internet import threads from sas.qtgui.Calculators.ResolutionCalculatorPanel import ResolutionCalculatorPanel -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator BG_COLOR_ERR = 'background-color: rgb(244, 170, 164);' @@ -26,7 +26,7 @@ def widget(self, qapp): """Create/Destroy the ResolutionCalculatorPanel""" class dummy_manager: def communicator(widget): - return Communicate() + return communicator w = ResolutionCalculatorPanel(dummy_manager()) diff --git a/src/sas/qtgui/MainWindow/CategoryManager.py b/src/sas/qtgui/MainWindow/CategoryManager.py index 86ecec784c..9a7bd77e49 100644 --- a/src/sas/qtgui/MainWindow/CategoryManager.py +++ b/src/sas/qtgui/MainWindow/CategoryManager.py @@ -7,6 +7,7 @@ from sasmodels.sasview_model import load_standard_models from sas.qtgui.Utilities.CategoryInstaller import CategoryInstaller +from sas.qtgui.Utilities.GuiUtils import communicator from .UI.CategoryManagerUI import Ui_CategoryManagerUI from .UI.ChangeCategoryUI import Ui_ChangeCategoryUI @@ -134,7 +135,7 @@ def __init__(self, parent=None, manager=None): super(CategoryManager, self).__init__(parent) self.setupUi(self) - self.communicator = manager.communicator() + self.communicator = communicator self.manager = manager diff --git a/src/sas/qtgui/MainWindow/DataExplorer.py b/src/sas/qtgui/MainWindow/DataExplorer.py index bf8588cb8d..06070a6d6f 100644 --- a/src/sas/qtgui/MainWindow/DataExplorer.py +++ b/src/sas/qtgui/MainWindow/DataExplorer.py @@ -98,7 +98,7 @@ def __init__(self, parent=None, guimanager=None, manager=None): self.cbSelect.activated.connect(self.selectData) self.currentChanged.connect(self.onTabSwitch) - self.communicator = self.parent.communicator() + self.communicator = GuiUtils.communicator self.communicator.fileTriggerSignal.connect(self.loadFromArbitraryPath) self.communicator.fileReadSignal.connect(self.loadFromURL) self.communicator.activeGraphsSignal.connect(self.updateGraphCount) @@ -111,9 +111,6 @@ def __init__(self, parent=None, guimanager=None, manager=None): self.communicator.updateModelFromPerspectiveSignal.connect(self.updateModelFromPerspective) self.communicator.freezeDataNameSignal.connect(self.freezeFromName) - # fixing silly naming clash in other managers - self.communicate = self.communicator - self.cbgraph.editTextChanged.connect(self.enableGraphCombo) self.cbgraph.currentIndexChanged.connect(self.enableGraphCombo) diff --git a/src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py b/src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py index 587a068848..1356f7d351 100644 --- a/src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py +++ b/src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py @@ -7,6 +7,7 @@ # UI from sas.qtgui.UI import main_resources_rc # noqa: F401 +from sas.qtgui.Utilities.GuiUtils import communicator class DroppableDataLoadWidget(QtWidgets.QTabWidget, Ui_DataLoadWidget): @@ -20,7 +21,7 @@ def __init__(self, parent=None, guimanager=None): # Enable file drag-drop on treeView self.setAcceptDrops(True) - self.communicator = guimanager.communicator() + self.communicator = communicator flags = QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint self.setWindowFlags(flags) diff --git a/src/sas/qtgui/MainWindow/GuiManager.py b/src/sas/qtgui/MainWindow/GuiManager.py index 961ec9b358..fafc1efd33 100644 --- a/src/sas/qtgui/MainWindow/GuiManager.py +++ b/src/sas/qtgui/MainWindow/GuiManager.py @@ -503,10 +503,6 @@ def updatePerspective(self, data): msg = "No perspective is currently active." logger.info(msg) - def communicator(self): - """ Accessor for the communicator """ - return self.communicate - def perspective(self): """ Accessor for the perspective """ return self._current_perspective @@ -587,7 +583,7 @@ def quitApplication(self): # save the paths etc. self.saveCustomConfig() - self.communicate.closeSignal.emit() + self.communicator.closeSignal.emit() reactor.callFromThread(reactor.stop) return True @@ -635,17 +631,17 @@ def processVersion(self, version_info: tuple[str, str, Version]): webbrowser.open(version_info["download_url"]) else: webbrowser.open(web.download_url) - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) else: msg = "You have the latest version" - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) except: msg = "guiframe: could not get latest application" msg += " version number\n %s" % sys.exc_info()[1] logger.error(msg) msg = "Could not connect to the application server." msg += " Please try again later." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) def actionWelcome(self): """ Show the Welcome panel """ @@ -669,18 +665,18 @@ def addCallbacks(self): """ Method defining all signal connections for the gui manager """ - self.communicate = GuiUtils.communicate - self.communicate.fileDataReceivedSignal.connect(self.fileWasRead) - self.communicate.statusBarUpdateSignal.connect(self.updateStatusBar) - self.communicate.updatePerspectiveWithDataSignal.connect(self.updatePerspective) - self.communicate.progressBarUpdateSignal.connect(self.updateProgressBar) - self.communicate.perspectiveChangedSignal.connect(self.perspectiveChanged) - self.communicate.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective) - self.communicate.deleteIntermediateTheoryPlotsSignal.connect(self.deleteIntermediateTheoryPlotsByTabId) - self.communicate.plotRequestedSignal.connect(self.showPlot) - self.communicate.plotFromNameSignal.connect(self.showPlotFromName) - self.communicate.updateModelFromDataOperationPanelSignal.connect(self.updateModelFromDataOperationPanel) - self.communicate.activeGraphsSignal.connect(self.updatePlotItems) + self.communicator = GuiUtils.communicator + self.communicator.fileDataReceivedSignal.connect(self.fileWasRead) + self.communicator.statusBarUpdateSignal.connect(self.updateStatusBar) + self.communicator.updatePerspectiveWithDataSignal.connect(self.updatePerspective) + self.communicator.progressBarUpdateSignal.connect(self.updateProgressBar) + self.communicator.perspectiveChangedSignal.connect(self.perspectiveChanged) + self.communicator.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective) + self.communicator.deleteIntermediateTheoryPlotsSignal.connect(self.deleteIntermediateTheoryPlotsByTabId) + self.communicator.plotRequestedSignal.connect(self.showPlot) + self.communicator.plotFromNameSignal.connect(self.showPlotFromName) + self.communicator.updateModelFromDataOperationPanelSignal.connect(self.updateModelFromDataOperationPanel) + self.communicator.activeGraphsSignal.connect(self.updatePlotItems) def addTriggers(self): @@ -784,8 +780,8 @@ def addTriggers(self): self._workspace.actionCheck_for_update.triggered.connect(self.actionCheck_for_update) self._workspace.actionWhat_s_New.triggered.connect(self.actionWhatsNew) - self.communicate.sendDataToGridSignal.connect(self.showBatchOutput) - self.communicate.resultPlotUpdateSignal.connect(self.showFitResults) + self.communicator.sendDataToGridSignal.connect(self.showBatchOutput) + self.communicator.resultPlotUpdateSignal.connect(self.showFitResults) #============ FILE ================= @@ -1008,7 +1004,7 @@ def actionData_Operation(self): """ """ data, theory = self.filesWidget.getAllFlatData() - self.communicate.sendDataToPanelSignal.emit(dict(data, **theory)) + self.communicator.sendDataToPanelSignal.emit(dict(data, **theory)) self.DataOperation.show() @@ -1203,7 +1199,7 @@ def actionAddMult_Models(self): def actionEditMask(self): - self.communicate.extMaskEditorSignal.emit() + self.communicator.extMaskEditorSignal.emit() #============ ANALYSIS ================= def actionFitting(self): diff --git a/src/sas/qtgui/MainWindow/MainWindow.py b/src/sas/qtgui/MainWindow/MainWindow.py index c75c8fa2a3..ac908a38e1 100644 --- a/src/sas/qtgui/MainWindow/MainWindow.py +++ b/src/sas/qtgui/MainWindow/MainWindow.py @@ -128,7 +128,7 @@ def run_sasview(file_list: list[str] | None = None): # Trigger an event to pass the filepath(s) to the GUI without requiring an API change if file_list: for file in file_list: - mainwindow.guiManager.communicate.fileTriggerSignal.emit(file) + mainwindow.guiManager.communicator.fileTriggerSignal.emit(file) timer = QTimer() timer.timeout.connect(lambda: None) diff --git a/src/sas/qtgui/MainWindow/NameChanger.py b/src/sas/qtgui/MainWindow/NameChanger.py index 35d7bd0897..7f04872ce4 100644 --- a/src/sas/qtgui/MainWindow/NameChanger.py +++ b/src/sas/qtgui/MainWindow/NameChanger.py @@ -18,7 +18,7 @@ def __init__(self, parent=None): self.setModal(True) self.parent = parent - self.communicator = self.parent.communicator + self.communicator = GuiUtils.communicator self.communicator.dataDeletedSignal.connect(self.removeData) self.manager = self.parent.manager diff --git a/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py b/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py index 7e53aed303..68e467d4a1 100644 --- a/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py +++ b/src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py @@ -18,7 +18,7 @@ # Local from sas.qtgui.Plotting.PlotterData import Data1D, Data2D, DataRole from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy -from sas.qtgui.Utilities.GuiUtils import Communicate, HashableStandardItem +from sas.qtgui.Utilities.GuiUtils import HashableStandardItem, communicator from sas.system.version import __version__ as SASVIEW_VERSION @@ -27,7 +27,7 @@ def __init__(self): self.name = "Dummy Perspective" def communicator(self): - return Communicate() + return communicator def allowBatch(self): return True @@ -50,7 +50,7 @@ def __init__(self): self._perspective = MyPerspective() def communicator(self): - return Communicate() + return communicator def perspective(self): return self._perspective diff --git a/src/sas/qtgui/MainWindow/UnitTesting/DroppableDataLoadWidgetTest.py b/src/sas/qtgui/MainWindow/UnitTesting/DroppableDataLoadWidgetTest.py index c68d680873..50d4aab5b6 100644 --- a/src/sas/qtgui/MainWindow/UnitTesting/DroppableDataLoadWidgetTest.py +++ b/src/sas/qtgui/MainWindow/UnitTesting/DroppableDataLoadWidgetTest.py @@ -5,7 +5,7 @@ from sas.qtgui.MainWindow.DroppableDataLoadWidget import DroppableDataLoadWidget from sas.qtgui.MainWindow.UnitTesting.DataExplorerTest import MyPerspective from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class DroppableDataLoadWidgetTest: @@ -16,7 +16,7 @@ def form(self, qapp): '''Create/Destroy the DroppableDataLoadWidget''' class dummy_manager: def communicator(self): - return Communicate() + return communicator def perspective(self): return MyPerspective() diff --git a/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py b/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py index db5c0ce816..99e2ad39d8 100644 --- a/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py +++ b/src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py @@ -160,7 +160,7 @@ def testProcessVersion(self, manager, mocker): """ # 1. version = 0.0.0 version_info = {"version": "0.0.0"} - spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal) + spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal) manager.processVersion(version_info) @@ -170,7 +170,7 @@ def testProcessVersion(self, manager, mocker): # 2. version < config.__version__ version_info = {"version": "0.0.1"} - spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal) + spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal) manager.processVersion(version_info) @@ -180,7 +180,7 @@ def testProcessVersion(self, manager, mocker): # 3. version > LocalConfig.__version__ version_info = {"version": "999.0.0"} - spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal) + spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal) mocker.patch.object(webbrowser, "open") manager.processVersion(version_info) @@ -194,7 +194,7 @@ def testProcessVersion(self, manager, mocker): # 4. couldn't load version version_info = {} mocker.patch.object(logger, "error") - spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal) + spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal) manager.processVersion(version_info) diff --git a/src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py b/src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py index 9bc9cd40f0..49370ce4c0 100644 --- a/src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py +++ b/src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py @@ -66,8 +66,8 @@ def __init__(self, parent=None): self.mapper = None self._path = "" self.model = QtGui.QStandardItemModel(self) - self.communicate = self.parent.communicator() - self.communicate.dataDeletedSignal.connect(self.removeData) + self.communicator = GuiUtils.communicator + self.communicator.dataDeletedSignal.connect(self.removeData) self._allow_close = False self._model_item: QStandardItem | None = None diff --git a/src/sas/qtgui/Perspectives/Corfunc/UnitTesting/CorfuncTest.py b/src/sas/qtgui/Perspectives/Corfunc/UnitTesting/CorfuncTest.py index f52e4f3000..d9f682a92d 100755 --- a/src/sas/qtgui/Perspectives/Corfunc/UnitTesting/CorfuncTest.py +++ b/src/sas/qtgui/Perspectives/Corfunc/UnitTesting/CorfuncTest.py @@ -26,10 +26,7 @@ def __init__(self, widget): self.filesWidget = MainWindow() def communicator(self, widget): - return GuiUtils.Communicate() - - def communicate(self, widget): - return GuiUtils.Communicate() + return GuiUtils.communicator w = CorfuncWindow(dummy_manager()) reference_data1 = Data1D(x=[0.1, 0.2, 0.3, 0.4, 0.5], y=[1000, 1000, 100, 10, 1], dy=[0.0, 0.0, 0.0, 0.0, 0.0]) diff --git a/src/sas/qtgui/Perspectives/Fitting/ConstraintManager.py b/src/sas/qtgui/Perspectives/Fitting/ConstraintManager.py index 99807bd553..f055629fe1 100644 --- a/src/sas/qtgui/Perspectives/Fitting/ConstraintManager.py +++ b/src/sas/qtgui/Perspectives/Fitting/ConstraintManager.py @@ -184,7 +184,7 @@ def addConstraintToRow(self, constraint: Constraint | None = None, row: int = 0, # update the main parameter list so the constrained parameter gets # updated when fitting self.widget.checkboxSelected(model.item(row, 0), model_key=model_key) - self.widget.communicate.statusBarUpdateSignal.emit('Constraint added') + self.widget.communicator.statusBarUpdateSignal.emit('Constraint added') if constraint_tab: # Set the constraint_accepted flag to True to inform the @@ -246,7 +246,7 @@ def addSimpleConstraint(self) -> None: brush = QtGui.QBrush(QtGui.QColor('blue')) self.widget.modifyViewOnRow(row, font=font, brush=brush, model_key=model_key) - self.widget.communicate.statusBarUpdateSignal.emit('Constraint added') + self.widget.communicator.statusBarUpdateSignal.emit('Constraint added') def editConstraint(self) -> None: """ @@ -370,7 +370,7 @@ def deleteConstraintOnParameter(self, param: str | None = None, model_key: str = self.widget.constraintAddedSignal.emit([row], model_key) self.widget.modifyViewOnRow(row, model_key=model_key) - self.widget.communicate.statusBarUpdateSignal.emit('Constraint removed') + self.widget.communicator.statusBarUpdateSignal.emit('Constraint removed') def getConstraintForRow(self, row: int, model_key: str = "standard") -> Constraint | None: """ diff --git a/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py b/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py index 8cd95e7d88..d2505b0f9d 100644 --- a/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/ConstraintWidget.py @@ -387,7 +387,7 @@ def onFit(self): # modify the Fit button self.cmdFit.setStyleSheet('QPushButton {color: red;}') self.cmdFit.setText('Stop fit') - self.parent.communicate.statusBarUpdateSignal.emit('Fitting started...') + self.parent.communicator.statusBarUpdateSignal.emit('Fitting started...') self.is_running = True def onHelp(self): @@ -445,7 +445,7 @@ def onTabCellEdit(self, row, column): msg = "Please use a non-empty name." else: msg = "Please use a unique name." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) item.setToolTip(msg) return @@ -455,7 +455,7 @@ def onTabCellEdit(self, row, column): self.cmdFit.setEnabled(True) item.setToolTip("") msg = f"Fitpage name changed to {new_moniker}." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) if not self.current_cell: return @@ -487,7 +487,7 @@ def onTabCellEdit(self, row, column): self.tblTabList.blockSignals(False) self.cmdFit.setEnabled(False) msg = "Weighting must be a numerical value (integer or float)." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) item.setToolTip(msg) return @@ -643,13 +643,13 @@ def fitComplete(self, result): # Assure the fitting succeeded if not result or not result[0] or not result[0][0]: msg = "Fitting failed." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) return if isinstance(result[0], str): msg = ("Fitting failed with the following message: " + result[0]) - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) return # Get the results list @@ -662,7 +662,7 @@ def fitComplete(self, result): else: msg = ("Fitting failed. Please ensure correctness of " + "chosen constraints.") - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) return # get the elapsed time @@ -682,7 +682,7 @@ def fitComplete(self, result): tab_object.fitComplete(([[results[i]]], elapsed)) msg = "Fitting completed successfully in: %s s.\n" % GuiUtils.formatNumber(elapsed) - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) def onBatchFitComplete(self, result): """ @@ -703,7 +703,7 @@ def batchComplete(self, result): self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) if result is None: msg = "Fitting failed." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) return # get the elapsed time @@ -719,17 +719,17 @@ def batchComplete(self, result): else: msg = ("Fitting failed. Please ensure correctness of " + "chosen constraints.") - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) return # Show the grid panel page_name = "ConstSimulPage" results = copy.deepcopy(result[0]) results.append(page_name) - self.parent.communicate.sendDataToGridSignal.emit(results) + self.parent.communicator.sendDataToGridSignal.emit(results) msg = "Fitting completed successfully in: %s s.\n" % GuiUtils.formatNumber(elapsed) - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) def onFitFailed(self, reason): """ @@ -750,7 +750,7 @@ def fitFailed(self, reason): self.parent.fittingStoppedSignal.emit(self.getTabsForFit()) msg = "Fitting failed: %s s.\n" % reason - self.parent.communicate.statusBarUpdateSignal.emit(msg) + self.parent.communicator.statusBarUpdateSignal.emit(msg) def isTabImportable(self, tab): """ diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingController.py b/src/sas/qtgui/Perspectives/Fitting/FittingController.py index ad9c47a66d..694e0b281a 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingController.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingController.py @@ -169,7 +169,7 @@ def paramDictFromResults(self, results: Any) -> dict[str, tuple[float, float]] | np.any(pvec is None) or \ not np.all(np.isfinite(pvec)): msg = "Fitting did not converge!" - self.widget.communicate.statusBarUpdateSignal.emit(msg) + GuiUtils.communicator.statusBarUpdateSignal.emit(msg) msg += results.mesg logger.error(msg) return None diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py index f81ce04d96..30e1446d8e 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py @@ -57,14 +57,14 @@ def __init__(self, parent=None, data=None): self.lastTabClosed = None self.installEventFilter(self) - self.communicate = self.parent.communicator() + self.communicator = GuiUtils.communicator # Initialize the first tab self.addFit(None) # Deal with signals self.tabCloseRequested.connect(self.tabCloses) - self.communicate.dataDeletedSignal.connect(self.dataDeleted) + self.communicator.dataDeletedSignal.connect(self.dataDeleted) self.fittingStartedSignal.connect(self.onFittingStarted) self.fittingStoppedSignal.connect(self.onFittingStopped) diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingState.py b/src/sas/qtgui/Perspectives/Fitting/FittingState.py index 90be1dfd43..1e8b370126 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingState.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingState.py @@ -52,7 +52,7 @@ class FittingState: on_model_changed: Callable[[], None] | None = None # Signal emitter for status updates - communicate: Any | None = None + communicator: Any | None = None def canHaveMagnetism(self, kernel_module: Any = None) -> bool: """ diff --git a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py index 19624cb52a..54596cfbb4 100644 --- a/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/FittingWidget.py @@ -342,7 +342,7 @@ def initializeGlobals(self) -> None: self.page_parameters = None # signal communicator - self.communicate = self.parent.communicate + self.communicator = GuiUtils.communicator def initializeWidgets(self) -> None: """ @@ -680,7 +680,7 @@ def initializeSignals(self) -> None: self.options_widget.txtMaxRange.editingFinished.connect(self.options_widget.updateMaxQ) # Signals from other widgets - self.communicate.customModelDirectoryChanged.connect(self.onCustomModelChange) + self.communicator.customModelDirectoryChanged.connect(self.onCustomModelChange) self.smearing_widget.smearingChangedSignal.connect(self.onSmearingOptionsUpdate) self.polydispersity_widget.cmdFitSignal.connect(lambda: self.cmdFit.setEnabled(self.haveParamsToFit())) self.polydispersity_widget.updateDataSignal.connect(lambda: self.updateData()) @@ -691,8 +691,8 @@ def initializeSignals(self) -> None: self.magnetism_widget.toggledSignal.connect(self.onMagnetismToggled) # Communicator signal - self.communicate.updateModelCategoriesSignal.connect(self.onCategoriesChanged) - self.communicate.updateMaskedDataSignal.connect(self.onMaskedData) + self.communicator.updateModelCategoriesSignal.connect(self.onCategoriesChanged) + self.communicator.updateMaskedDataSignal.connect(self.onMaskedData) # Catch all key press events self.keyPressedSignal.connect(self.onKey) @@ -1279,7 +1279,7 @@ def onSelectionChanged(self) -> None: rows = current_list.selectionModel().selectedRows() # Clean previous messages - self.communicate.statusBarUpdateSignal.emit("") + self.communicator.statusBarUpdateSignal.emit("") if len(rows) == 1: # Show constraint, if present row = rows[0].row() @@ -1296,7 +1296,7 @@ def onSelectionChanged(self) -> None: else: # ill defined constraint return - self.communicate.statusBarUpdateSignal.emit(update_text) + self.communicator.statusBarUpdateSignal.emit(update_text) def onSesansData(self) -> None: """ @@ -1499,7 +1499,7 @@ def onFit(self) -> None: fitters, _ = self.fitting_controller.prepareFitters() except ValueError as ex: # This should not happen! GUI explicitly forbids this situation - self.communicate.statusBarUpdateSignal.emit(str(ex)) + self.communicator.statusBarUpdateSignal.emit(str(ex)) return # keep local copy of kernel parameters, as they will change during the update @@ -1527,7 +1527,7 @@ def onFit(self) -> None: self.calc_fit.queue() self.calc_fit.ready(2.5) - self.communicate.statusBarUpdateSignal.emit('Fitting started...') + self.communicator.statusBarUpdateSignal.emit('Fitting started...') self.fit_started = True # Disable some elements @@ -1544,7 +1544,7 @@ def stopFit(self) -> None: self.enableInteractiveElements() msg = "Fitting cancelled." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) def updateFit(self) -> None: """ @@ -1557,7 +1557,7 @@ def fitFailed(self, reason: Any) -> None: """ self.enableInteractiveElements() msg = "Fitting failed with: "+ str(reason) - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) def batchFittingCompleted(self, result: tuple | None) -> None: """ @@ -1576,18 +1576,18 @@ def batchFitComplete(self, result: tuple) -> None: if len(result) == 0: msg = "Fitting failed." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) return # Show the grid panel page_name = "BatchPage" + str(self.tab_id) results = copy.deepcopy(result[0]) results.append(page_name) - self.communicate.sendDataToGridSignal.emit(results) + self.communicator.sendDataToGridSignal.emit(results) elapsed = result[1] msg = "Fitting completed successfully in: %s s.\n" % GuiUtils.formatNumber(elapsed) - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) # Run over the list of results and update the items for res_index, res_list in enumerate(result[0]): @@ -1639,7 +1639,7 @@ def fitComplete(self, result: tuple) -> None: if not result or not result[0] or not result[0][0]: msg = "Fitting failed." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) # reload the kernel_module in case it's corrupted self.kernel_module = copy.deepcopy(self.kernel_module_copy) return @@ -1648,7 +1648,7 @@ def fitComplete(self, result: tuple) -> None: self.fitResults = True if result is None or len(result) == 0 or len(result[0]) == 0: msg = "Fitting failed." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) return res_list = result[0][0] res = res_list[0] @@ -1659,7 +1659,7 @@ def fitComplete(self, result: tuple) -> None: return # Show bumps convergence plots - self.communicate.resultPlotUpdateSignal.emit(result[0]) + self.communicator.resultPlotUpdateSignal.emit(result[0]) elapsed = result[1] if self.calc_fit is not None and self.calc_fit._interrupting: @@ -1667,7 +1667,7 @@ def fitComplete(self, result: tuple) -> None: logger.warning("\n"+msg+"\n") else: msg = "Fitting completed successfully in: %s s." % GuiUtils.formatNumber(elapsed) - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) # Dictionary of fitted parameter: value, error # e.g. param_dic = {"sld":(1.703, 0.0034), "length":(33.455, -0.0983)} @@ -1791,7 +1791,7 @@ def showPlot(self) -> None: item = self._requestPlots(self.data.name, current_index.model()) if item: # fit+data has not been shown - show just data - self.communicate.plotRequestedSignal.emit([item, data_to_show]) + self.communicator.plotRequestedSignal.emit([item, data_to_show]) def _requestPlots(self, item_name: str, item_model: Any) -> Any | None: """ @@ -1805,7 +1805,7 @@ def _requestPlots(self, item_name: str, item_model: Any) -> Any | None: for item, plot in plots.items(): if plot.plot_role != DataRole.ROLE_DATA and fitpage_name in plot.name: data_shown = True - self.communicate.plotRequestedSignal.emit([item, plot]) + self.communicator.plotRequestedSignal.emit([item, plot]) # return the last data item seen, if nothing was plotted; supposed to be just data) return None if data_shown else item @@ -2380,7 +2380,7 @@ def createNewIndex(self, fitted_data: Data1D | Data2D) -> None: fitted_data.symbol = "Line" self.createTheoryIndex(fitted_data) # Switch to the theory tab for user's glee - self.communicate.changeDataExplorerTabSignal.emit(1) + self.communicator.changeDataExplorerTabSignal.emit(1) def updateModelIndex(self, fitted_data: Data1D | Data2D) -> None: """ @@ -2406,7 +2406,7 @@ def createTheoryIndex(self, fitted_data: Data1D | Data2D) -> None: fitted_data = temp_reader._remove_nans_in_data(fitted_data) # Modify the item or add it if new theory_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name) - self.communicate.updateTheoryFromPerspectiveSignal.emit(theory_item) + self.communicator.updateTheoryFromPerspectiveSignal.emit(theory_item) def setTheoryItem(self, item: Any) -> None: """ @@ -2581,7 +2581,7 @@ def complete1D(self, return_data: dict) -> None: else: # delete theory items for the model, in order to get rid of any # redundant items, e.g. beta(Q), S_eff(Q) - self.communicate.deleteIntermediateTheoryPlotsSignal.emit(str(self.tab_id)) + self.communicator.deleteIntermediateTheoryPlotsSignal.emit(str(self.tab_id)) self._appendPlotsPolyDisp(new_plots, return_data, fitted_data) @@ -2593,7 +2593,7 @@ def complete1D(self, return_data: dict) -> None: new_plots.append(plot) for plot in new_plots: - self.communicate.plotUpdateSignal.emit([plot]) + self.communicator.plotUpdateSignal.emit([plot]) QtWidgets.QApplication.processEvents() # Update radius_effective if relevant @@ -2626,7 +2626,7 @@ def complete2D(self, return_data: dict) -> None: # Update/generate plots for plot in new_plots: - self.communicate.plotUpdateSignal.emit([plot]) + self.communicator.plotUpdateSignal.emit([plot]) def updateEffectiveRadius(self, return_data: dict) -> None: """ diff --git a/src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py b/src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py index 03d5bb8647..5577ce19ea 100644 --- a/src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py +++ b/src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py @@ -138,7 +138,7 @@ def onMaskEdit(self): Callback for running the mask editor """ if isinstance(self.logic.data, Data2D): - self.parent.communicate.maskEditorSignal.emit(self.logic.data) + GuiUtils.communicator.maskEditorSignal.emit(self.logic.data) def onRangeReset(self): """ diff --git a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py index 87027501b9..242973d074 100755 --- a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py +++ b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ComplexConstraintTest.py @@ -22,7 +22,7 @@ def widget(self, qapp, mocker): '''Create/Destroy the ComplexConstraint''' class dummy_manager: HELP_DIRECTORY_LOCATION = "html" - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator '''Create ComplexConstraint dialog''' # need to ensure that categories exist first diff --git a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py index dcadb6cb97..97067d1a0b 100644 --- a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py +++ b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/ConstraintWidgetTest.py @@ -24,9 +24,7 @@ def widget(self, qapp, mocker): '''Create ConstraintWidget dialog''' class dummy_manager: - def communicator(self): - return GuiUtils.Communicate() - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator def __init__(self): self._perspective = dummy_perspective() @@ -260,7 +258,7 @@ def testOnAcceptConstraint(self, widget, mocker): def testFitComplete(self, widget, mocker): ''' test the handling of fit results''' mocker.patch.object(widget, 'getTabsForFit', return_value=[[None], [None]]) - spy = QSignalSpy(widget.parent.communicate.statusBarUpdateSignal) + spy = QSignalSpy(widget.parent.communicator.statusBarUpdateSignal) # test handling of fit error # result is None result = None @@ -293,9 +291,9 @@ def testFitComplete(self, widget, mocker): def testBatchFitComplete(self, widget, mocker): ''' test the handling of batch fit results''' mocker.patch.object(widget, 'getTabsForFit', return_value=[[None], [None]]) - spy = QSignalSpy(widget.parent.communicate.statusBarUpdateSignal) + spy = QSignalSpy(widget.parent.communicator.statusBarUpdateSignal) spy_data = QSignalSpy( - widget.parent.communicate.sendDataToGridSignal) + widget.parent.communicator.sendDataToGridSignal) # test handling of fit error # result is None result = None diff --git a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py index 94e174db88..e80ee215b2 100644 --- a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py +++ b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingPerspectiveTest.py @@ -16,9 +16,7 @@ class FittingPerspectiveTest: def widget(self, qapp): '''Create/Destroy the perspective''' class dummy_manager: - def communicator(self): - return GuiUtils.Communicate() - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator '''Create the perspective''' # need to ensure that categories exist first diff --git a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py index 738d38587b..1a775a9bf3 100644 --- a/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py +++ b/src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingWidgetTest.py @@ -26,7 +26,7 @@ class dummy_manager: HELP_DIRECTORY_LOCATION = "html" - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator def __init__(self): self._perspective = dummy_perspective() @@ -401,7 +401,7 @@ def testCreateTheoryIndex(self, widget): Test the data->QIndex conversion """ # set up the model update spy - spy = QtSignalSpy(widget._model_model, widget.communicate.updateTheoryFromPerspectiveSignal) + spy = QtSignalSpy(widget._model_model, widget.communicator.updateTheoryFromPerspectiveSignal) widget.show() # Change the category index so we have some models @@ -770,7 +770,7 @@ def testPlotTheory(self, widget): assert widget.cmdPlot.text() == 'Calculate' # Spying on plot update signal - spy = QtSignalSpy(widget, widget.communicate.plotRequestedSignal) + spy = QtSignalSpy(widget, widget.communicator.plotRequestedSignal) # Press Calculate QtTest.QTest.mouseClick(widget.cmdPlot, QtCore.Qt.LeftButton) @@ -811,7 +811,7 @@ def notestPlotData(self, widget): assert widget.cmdPlot.text() == 'Show Plot' # Spying on plot update signal - spy = QtSignalSpy(widget, widget.communicate.plotRequestedSignal) + spy = QtSignalSpy(widget, widget.communicator.plotRequestedSignal) # Press Calculate QtTest.QTest.mouseClick(widget.cmdPlot, QtCore.Qt.LeftButton) @@ -894,7 +894,7 @@ def notestOnFit1D(self, widget, mocker): widget.main_params_to_fit = ['scale'] # Spying on status update signal - update_spy = QtSignalSpy(widget, widget.communicate.statusBarUpdateSignal) + update_spy = QtSignalSpy(widget, widget.communicator.statusBarUpdateSignal) mocker.patch.object(threads, 'deferToThread') widget.onFit() @@ -939,7 +939,7 @@ def notestOnFit2D(self, widget): widget.main_params_to_fit = ['scale'] # Spying on status update signal - update_spy = QtSignalSpy(widget, widget.communicate.statusBarUpdateSignal) + update_spy = QtSignalSpy(widget, widget.communicator.statusBarUpdateSignal) with threads.deferToThread as MagicMock: widget.onFit() diff --git a/src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py b/src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py index 00052a1070..8fd1e7a11a 100644 --- a/src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py +++ b/src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py @@ -66,8 +66,8 @@ def __init__(self, parent=None): self._allow_close: bool = False # Communication - self.communicate = self._manager.communicator() - self.communicate.dataDeletedSignal.connect(self.removeData) + self.communicator = GuiUtils.communicator + self.communicator.dataDeletedSignal.connect(self.removeData) self.detailsDialog = DetailsDialog(self) self.detailsDialog.cmdOK.clicked.connect(self.enableStatus) @@ -390,7 +390,7 @@ def plot_result(self, model: QtGui.QStandardItemModel) -> None: plots.append(self.low_extrapolation_plot) if len(plots) > 1: - self.communicate.plotRequestedSignal.emit(plots) + self.communicator.plotRequestedSignal.emit(plots) # Update the details dialog in case it is open self.update_details_widget() diff --git a/src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantPerspectiveTest.py b/src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantPerspectiveTest.py index 05467018f9..f3e7513ede 100644 --- a/src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantPerspectiveTest.py +++ b/src/sas/qtgui/Perspectives/Invariant/UnitTesting/InvariantPerspectiveTest.py @@ -35,10 +35,7 @@ def __init__(self): self.filesWidget = MainWindow() def communicator(self): - return GuiUtils.Communicate() - - def communicate(self): - return GuiUtils.Communicate() + return GuiUtils.communicator def createGuiData(self, data_to_plot): # Pass data back - testing module - production createGuiData returns a QStandardItem diff --git a/src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py b/src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py index 71a2e8283a..7444a688cd 100644 --- a/src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py +++ b/src/sas/qtgui/Perspectives/Inversion/DMaxExplorerWidget.py @@ -50,7 +50,7 @@ def __init__(self, pr_state, nfunc, parent=None): self.pr_state = pr_state self.nfunc = nfunc - self.communicator = GuiUtils.Communicate() + self.communicator = GuiUtils.communicator self.plot = PlotterWidget(self, self) self.hasPlot = False diff --git a/src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py b/src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py index 578aefde66..83c2c5bb9c 100644 --- a/src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py +++ b/src/sas/qtgui/Perspectives/Inversion/InversionPerspective.py @@ -43,9 +43,8 @@ def __init__(self, parent=None,data=None): self.maxIndex = 1 # Needed for Batch inversion self.parent = parent - self.communicate = self.parent.communicate - #self.communicate = self.parent.communicator() - self.communicate.dataDeletedSignal.connect(self.removeData) + self.communicator = GuiUtils.communicator + self.communicator.dataDeletedSignal.connect(self.removeData) self.tabCloseRequested.connect(self.tabCloses) # List of active Pr Tabs @@ -191,10 +190,6 @@ def supports_reports(self): def supports_fitting(self): return False - def communicator(self): - return self.filesWidget.communicate - - def allowBatch(self): """ Tell the caller we accept batch mode diff --git a/src/sas/qtgui/Perspectives/Inversion/InversionWidget.py b/src/sas/qtgui/Perspectives/Inversion/InversionWidget.py index 4b268dd2ca..a8ac5d3c6f 100644 --- a/src/sas/qtgui/Perspectives/Inversion/InversionWidget.py +++ b/src/sas/qtgui/Perspectives/Inversion/InversionWidget.py @@ -17,6 +17,7 @@ Communicate, DoubleValidator, HashableStandardItem, + communicator, dataFromItem, updateModelItemWithPlot, ) @@ -93,7 +94,7 @@ def __init__(self, window, parent=None, data=None, tab_id=1, tab_name=''): self.tab_name = tab_name self.tab_id = tab_id - self.communicator: Communicate = self.parent.communicator() + self.communicator: Communicate = communicator # We're going to use this structure even if we're just dealing with one specific datum. Just that this list # would then have one item in it. diff --git a/src/sas/qtgui/Perspectives/Inversion/UnitTesting/InversionPerspectiveTest.py b/src/sas/qtgui/Perspectives/Inversion/UnitTesting/InversionPerspectiveTest.py index 493928ee0f..a61f90803f 100644 --- a/src/sas/qtgui/Perspectives/Inversion/UnitTesting/InversionPerspectiveTest.py +++ b/src/sas/qtgui/Perspectives/Inversion/UnitTesting/InversionPerspectiveTest.py @@ -11,7 +11,7 @@ from sas.qtgui.Perspectives.Inversion.InversionPerspective import InversionWindow from sas.qtgui.Perspectives.Inversion.InversionUtils import WIDGETS from sas.qtgui.Plotting.PlotterData import Data1D -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator logger = logging.getLogger(__name__) @@ -25,9 +25,7 @@ def widget(self, qapp, mocker): class dummy_manager: HELP_DIRECTORY_LOCATION = "html" - communicate = Communicate() - def communicator(self): - return self.communicate + communicator = communicator w = InversionWindow(parent=dummy_manager()) w._parent = QtWidgets.QMainWindow() diff --git a/src/sas/qtgui/Perspectives/SizeDistribution/SizeDistributionPerspective.py b/src/sas/qtgui/Perspectives/SizeDistribution/SizeDistributionPerspective.py index 0c70220c1d..d728e97741 100644 --- a/src/sas/qtgui/Perspectives/SizeDistribution/SizeDistributionPerspective.py +++ b/src/sas/qtgui/Perspectives/SizeDistribution/SizeDistributionPerspective.py @@ -68,8 +68,8 @@ def __init__(self, parent=None): self._parent = parent self._model_item = QtGui.QStandardItem() - self.communicate = parent.communicator() - self.communicate.dataDeletedSignal.connect(self.removeData) + self.communicator = GuiUtils.communicator + self.communicator.dataDeletedSignal.connect(self.removeData) self.logic = SizeDistributionLogic() @@ -104,9 +104,6 @@ def __init__(self, parent=None): ###################################################################### # Base Perspective Class Definitions - def communicator(self): - return self.communicate - def allowBatch(self): return False @@ -519,7 +516,7 @@ def plotData(self): GuiUtils.updateModelItemWithPlot(self._model_item, self.fit_plot, title) plots.append(self.fit_plot) - self.communicate.plotRequestedSignal.emit(plots) + self.communicator.plotRequestedSignal.emit(plots) def getState(self): """ @@ -672,7 +669,7 @@ def fitComplete(self, result: MaxEntResult) -> None: self.enableButtons() if result is None: msg = "Fitting failed." - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) return # update the output box @@ -695,7 +692,7 @@ def fitComplete(self, result: MaxEntResult) -> None: title = self.trust_plot.name GuiUtils.updateModelItemWithPlot(self._model_item, self.trust_plot, title) plots.append(self.trust_plot) - self.communicate.plotRequestedSignal.emit(plots) + self.communicator.plotRequestedSignal.emit(plots) # add fit to data plot if isinstance(result.data_max_ent, LoadData1D): diff --git a/src/sas/qtgui/Perspectives/SizeDistribution/UnitTesting/SizeDistributionPerspectiveTest.py b/src/sas/qtgui/Perspectives/SizeDistribution/UnitTesting/SizeDistributionPerspectiveTest.py index b4425929c7..6c058ae128 100644 --- a/src/sas/qtgui/Perspectives/SizeDistribution/UnitTesting/SizeDistributionPerspectiveTest.py +++ b/src/sas/qtgui/Perspectives/SizeDistribution/UnitTesting/SizeDistributionPerspectiveTest.py @@ -10,7 +10,7 @@ SizeDistributionWindow, ) from sas.qtgui.Plotting.PlotterData import Data1D -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class SizeDistributionTest: @@ -22,10 +22,7 @@ def widget(self, qtbot): class dummy_manager: HELP_DIRECTORY_LOCATION = "html" - communicate = Communicate() - - def communicator(self): - return self.communicate + communicator = communicator w = SizeDistributionWindow(parent=dummy_manager()) w._parent = QtWidgets.QMainWindow() diff --git a/src/sas/qtgui/Plotting/Plotter.py b/src/sas/qtgui/Plotting/Plotter.py index 62cd5dcd11..333b20c291 100644 --- a/src/sas/qtgui/Plotting/Plotter.py +++ b/src/sas/qtgui/Plotting/Plotter.py @@ -1004,7 +1004,7 @@ def onMplMouseDown(self, event): x_str = GuiUtils.formatNumber(self.x_click) y_str = GuiUtils.formatNumber(self.y_click) coord_str = f"x: {x_str}, y: {y_str}" - self.manager.communicator.statusBarUpdateSignal.emit(coord_str) + GuiUtils.communicator.statusBarUpdateSignal.emit(coord_str) def onMplMouseUp(self, event): """ diff --git a/src/sas/qtgui/Plotting/Plotter2D.py b/src/sas/qtgui/Plotting/Plotter2D.py index 8b8b9d11f3..202dd28d9c 100644 --- a/src/sas/qtgui/Plotting/Plotter2D.py +++ b/src/sas/qtgui/Plotting/Plotter2D.py @@ -374,7 +374,7 @@ def slicer_closed(): self.slicer_widget = SlicerParameters(self, model=self.param_model, active_plots=self.getActivePlots(), validate_method=validator, - communicator=self.manager.communicator) + communicator=GuiUtils.communicator) self.slicer_widget.closeWidgetSignal.connect(slicer_closed) # Add the plot to the workspace self.slicer_subwindow = self.manager.parent.workspace().addSubWindow(self.slicer_widget) @@ -436,8 +436,8 @@ def onCircularAverage(self): GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) - self.manager.communicator.plotUpdateSignal.emit([new_plot]) - self.manager.communicator.forcePlotDisplaySignal.emit([item, new_plot]) + GuiUtils.communicator.plotUpdateSignal.emit([new_plot]) + GuiUtils.communicator.forcePlotDisplaySignal.emit([item, new_plot]) def updateCircularAverage(self): """ @@ -471,7 +471,7 @@ def updateCircularAverage(self): # Overwrite existing plot GuiUtils.updateModelItemWithPlot(item, new_plot, new_plot.id) # Show the new plot, if already visible - self.manager.communicator.plotUpdateSignal.emit([new_plot]) + GuiUtils.communicator.plotUpdateSignal.emit([new_plot]) def updateSlicer(self): """ @@ -878,7 +878,7 @@ def onMplMouseDown(self, event): x_str = GuiUtils.formatNumber(x_click) y_str = GuiUtils.formatNumber(y_click) coord_str = f"x: {x_str}, y: {y_str}" - self.manager.communicate.statusBarUpdateSignal.emit(coord_str) + GuiUtils.communicator.statusBarUpdateSignal.emit(coord_str) class Plotter2D(QtWidgets.QDialog, Plotter2DWidget): """ diff --git a/src/sas/qtgui/Plotting/PlotterBase.py b/src/sas/qtgui/Plotting/PlotterBase.py index ded2ffd020..3aa0279a26 100644 --- a/src/sas/qtgui/Plotting/PlotterBase.py +++ b/src/sas/qtgui/Plotting/PlotterBase.py @@ -36,7 +36,7 @@ def add_custom_button(self): def sendToDataExplorer(self): for item in self.parent.data: - self.parent.manager.communicator.freezeDataNameSignal.emit(item.name) + GuiUtils.communicator.freezeDataNameSignal.emit(item.name) class PlotterBase(QtWidgets.QWidget): #TODO: Describe what this class is @@ -248,7 +248,7 @@ def updatePlotHelper(self): # Notify the helper PlotHelper.addPlot(self) # Notify the listeners about a new graph - self.manager.communicator.activeGraphsSignal.emit([self, False]) + GuiUtils.communicator.activeGraphsSignal.emit([self, False]) def defaultContextMenu(self): """ @@ -354,7 +354,7 @@ def closeEvent(self, event): PlotHelper.deletePlot(PlotHelper.idOfPlot(self)) # Notify the listeners - self.manager.communicator.activeGraphsSignal.emit([self, True]) + GuiUtils.communicator.activeGraphsSignal.emit([self, True]) event.accept() @@ -436,7 +436,7 @@ def onWindowsTitle(self): title = titleWidget.title() self.setWindowTitle(title) # Notify the listeners about a new graph title - self.manager.communicator.activeGraphName.emit((current_title, title)) + GuiUtils.communicator.activeGraphName.emit((current_title, title)) def onToggleMenu(self): """ diff --git a/src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py b/src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py index a6fc69e9a9..36743ab00b 100644 --- a/src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py +++ b/src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py @@ -14,7 +14,7 @@ import sas.qtgui.Plotting.Plotter2D as Plotter2D from sas.qtgui.MainWindow.UnitTesting.DataExplorerTest import MyPerspective from sas.qtgui.Plotting.PlotterData import Data2D -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class Plotter2DTest: @@ -25,7 +25,7 @@ def plotter(self, qapp): class dummy_manager: def communicator(self): - return Communicate() + return communicator def perspective(self): return MyPerspective() def workspace(self): diff --git a/src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py b/src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py index 90221b24e2..3dce7540e5 100644 --- a/src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py +++ b/src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py @@ -15,7 +15,7 @@ from sas.qtgui.MainWindow.UnitTesting.DataExplorerTest import MyPerspective from sas.qtgui.Plotting.ScaleProperties import ScaleProperties from sas.qtgui.Plotting.WindowTitle import WindowTitle -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class PlotterBaseTest: @@ -26,7 +26,7 @@ def plotter(self, qapp): '''Create/Destroy the AboutBox''' class dummy_manager: def communicator(self): - return Communicate() + return communicator def perspective(self): return MyPerspective() diff --git a/src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py b/src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py index b59c47fbef..aaa585a433 100644 --- a/src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py +++ b/src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py @@ -13,14 +13,13 @@ # Local from sas.qtgui.Plotting.SlicerParameters import SlicerParameters from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class dummy_manager: # def communicator(self): - # return Communicate() - communicator = Communicate() - communicate = Communicate() + # return communicator + communicator = communicator active_plots = {} @@ -58,7 +57,7 @@ def widget(self, qapp, data): active_plots = {"test_plot": plotter} w = SlicerParameters(model=model, parent=plotter, active_plots=active_plots, - communicator=dummy_manager().communicate) + communicator=dummy_manager().communicator) yield w w.close() @@ -100,7 +99,7 @@ def testLstParams(self, widget, data): active_plots = {"test_plot": plotter} widget = SlicerParameters(model=model, parent=plotter, active_plots=active_plots, - communicator=dummy_manager().communicate) + communicator=dummy_manager().communicator) assert widget.proxy.columnCount() == 2 assert widget.proxy.rowCount() == 2 assert widget.model.item(0, 0).text() == 't1' diff --git a/src/sas/qtgui/UnitTesting/TestUtilsTest.py b/src/sas/qtgui/UnitTesting/TestUtilsTest.py index 2737dff8a8..8364053e64 100644 --- a/src/sas/qtgui/UnitTesting/TestUtilsTest.py +++ b/src/sas/qtgui/UnitTesting/TestUtilsTest.py @@ -3,7 +3,7 @@ from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy # Local -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class TestUtilsTest: @@ -17,7 +17,7 @@ def signalReceived(signal): # Test the signal callback assert signal == test_string - communicator = Communicate() + communicator = communicator communicator.statusBarUpdateSignal.connect(signalReceived) # Define the signal spy for testing diff --git a/src/sas/qtgui/Utilities/DocViewWidget.py b/src/sas/qtgui/Utilities/DocViewWidget.py index cf624533bf..280138f520 100644 --- a/src/sas/qtgui/Utilities/DocViewWidget.py +++ b/src/sas/qtgui/Utilities/DocViewWidget.py @@ -40,8 +40,8 @@ def __init__(self, source: Path): # Necessary globals self.source: Path = Path(source) - from sas.qtgui.Utilities.GuiUtils import communicate - self.communicate = communicate + from sas.qtgui.Utilities.GuiUtils import communicator + self.communicator = communicator self.initializeSignals() # Connect signals self.initialLoadHtml() @@ -49,7 +49,7 @@ def __init__(self, source: Path): def initializeSignals(self): """Initialize all external signals that will trigger events for the window.""" self.closeButton.clicked.connect(self.onCloseButtonClicked) - self.communicate.closeSignal.connect(self.onCloseButtonClicked) + self.communicator.closeSignal.connect(self.onCloseButtonClicked) self.webEngineViewer.urlChanged.connect(self.updateTitle) self.webEngineViewer.page().profile().downloadRequested.connect(self.onDownload) diff --git a/src/sas/qtgui/Utilities/FileConverter.py b/src/sas/qtgui/Utilities/FileConverter.py index 605693b128..555a111d18 100644 --- a/src/sas/qtgui/Utilities/FileConverter.py +++ b/src/sas/qtgui/Utilities/FileConverter.py @@ -145,12 +145,12 @@ def onConvert(self): return # everything converted, notify the user logger.info("File successfully converted.") - self.parent.communicate.statusBarUpdateSignal.emit("File converted successfully.") + GuiUtils.communicator.statusBarUpdateSignal.emit("File converted successfully.") # Optionally, load the freshly converted file into Data Explorer if self.chkLoadFile.isChecked(): # awful climbing up the hierarchy... don't do that. please. - self.parent.filesWidget.loadFromURL([self.ofile]) + GuiUtils.communicator.fileReadSignal.emit([self.ofile]) def onHelp(self): """ diff --git a/src/sas/qtgui/Utilities/GridPanel.py b/src/sas/qtgui/Utilities/GridPanel.py index 603d0f4f89..45f3a86467 100644 --- a/src/sas/qtgui/Utilities/GridPanel.py +++ b/src/sas/qtgui/Utilities/GridPanel.py @@ -29,7 +29,7 @@ def __init__(self, parent=None, output_data=None): self.setupUi(self) self.parent = parent - self.communicate = GuiUtils.communicate + self.communicator = GuiUtils.communicator self.addToolbarActions() @@ -194,7 +194,7 @@ def onPlot(self): rows = [s.row() for s in self.currentTable().selectionModel().selectedRows()] if not rows: msg = "Nothing to plot!" - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) return data = self.dataFromTable(self.currentTable()) # data['Data'] -> ['filename1', 'filename2', ...] @@ -203,7 +203,7 @@ def onPlot(self): try: name = data['Data'][row] # emit a signal so the plots are being shown - self.communicate.plotFromNameSignal.emit(name) + self.communicator.plotFromNameSignal.emit(name) # This is an important processEvent. # This allows charts to be properly updated in order # of plots being applied. @@ -248,10 +248,10 @@ def actionSendToExcel(self): url = QUrl.fromLocalFile(self.grid_filename) if QDesktopServices.openUrl(url): - self.parent.communicate.statusBarUpdateSignal.emit("Success: " + self.communicator.statusBarUpdateSignal.emit("Success: " "The batch results CSV file successfully opened in your system CSV viewer.") else: - self.parent.communicate.statusBarUpdateSignal.emit("Failure: A CSV viewer " + self.communicator.statusBarUpdateSignal.emit("Failure: A CSV viewer " "is required to view the batch results. Please set one in your default " "app settings to change this behavior.") @@ -581,7 +581,7 @@ def onPlot(self): rows = [s.row() for s in self.currentTable().selectionModel().selectedRows()] if not rows: msg = "Nothing to plot!" - self.communicate.statusBarUpdateSignal.emit(msg) + self.communicator.statusBarUpdateSignal.emit(msg) return data = self.dataFromTable(self.currentTable()) # data['Data'] -> ['filename1', 'filename2', ...] diff --git a/src/sas/qtgui/Utilities/GuiUtils.py b/src/sas/qtgui/Utilities/GuiUtils.py index c7bebbbceb..81cc6c7a68 100644 --- a/src/sas/qtgui/Utilities/GuiUtils.py +++ b/src/sas/qtgui/Utilities/GuiUtils.py @@ -183,7 +183,7 @@ class Communicate(QtCore.QObject): # Notify about a data name to be frozen and send to fitting perspective freezeDataNameSignal = QtCore.Signal(str) -communicate = Communicate() +communicator = Communicate() def updateModelItemWithPlot(item, update_data, name="", checkbox_state=None): diff --git a/src/sas/qtgui/Utilities/ImageViewer.py b/src/sas/qtgui/Utilities/ImageViewer.py index 0448747324..56b2783681 100644 --- a/src/sas/qtgui/Utilities/ImageViewer.py +++ b/src/sas/qtgui/Utilities/ImageViewer.py @@ -251,7 +251,7 @@ def convertImage(self, rgb, xmin, xmax, ymin, ymax, zscale): # Create item and add to the data explorer try: item = GuiUtils.createModelItemWithPlot(output, output.filename) - self.parent.communicate.updateModelFromPerspectiveSignal.emit(item) + GuiUtils.communicator.updateModelFromPerspectiveSignal.emit(item) except Exception as ex: err_msg = "Failed to create new index '%s'.\n" % str(ex) logger.error(err_msg) diff --git a/src/sas/qtgui/Utilities/ModelEditors/AddMultEditor/AddMultEditor.py b/src/sas/qtgui/Utilities/ModelEditors/AddMultEditor/AddMultEditor.py index 4af0277c31..a020e0f6e7 100644 --- a/src/sas/qtgui/Utilities/ModelEditors/AddMultEditor/AddMultEditor.py +++ b/src/sas/qtgui/Utilities/ModelEditors/AddMultEditor/AddMultEditor.py @@ -222,20 +222,20 @@ def onApply(self): logger.error(traceback_to_show) # Set the status bar message - self.parent.communicate.statusBarUpdateSignal.emit("Model check failed") + GuiUtils.communicator.statusBarUpdateSignal.emit("Model check failed") return if not success: return # Update list of models in FittingWidget and AddMultEditor - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() self.updateModels() # Notify the user title = self.txtName.text().lstrip().rstrip() msg = "Custom model "+title + " successfully created." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + GuiUtils.communicator.statusBarUpdateSignal.emit(msg) logger.info(msg) def write_new_model_to_file(self, fname, model1_name, model2_name, operator): diff --git a/src/sas/qtgui/Utilities/ModelEditors/ReparamEditor/ReparameterizationEditor.py b/src/sas/qtgui/Utilities/ModelEditors/ReparamEditor/ReparameterizationEditor.py index 221bff9582..07b4ce24d0 100644 --- a/src/sas/qtgui/Utilities/ModelEditors/ReparamEditor/ReparameterizationEditor.py +++ b/src/sas/qtgui/Utilities/ModelEditors/ReparamEditor/ReparameterizationEditor.py @@ -296,7 +296,7 @@ def onApply(self): # Write the new model to the file model_text = self.generateModelText() self.writeModel(output_file_path, model_text) - self.parent.communicate.customModelDirectoryChanged.emit() # Refresh the list of custom models + GuiUtils.communicator.customModelDirectoryChanged.emit() # Refresh the list of custom models # Test the model for errors (file must be generated first) error_line = self.checkModel(output_file_path) @@ -308,7 +308,7 @@ def onApply(self): # Notify user that model was written sucessfully msg = f"Reparameterized model {model_name} successfully created." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + GuiUtils.communicator.statusBarUpdateSignal.emit(msg) logger.info(msg) self.is_modified = False @@ -453,8 +453,8 @@ def checkModel(self, full_path: str | pathlib.Path) -> int: logger.error(traceback_to_show) # Set the status bar message - # GuiUtils.Communicate.statusBarUpdateSignal.emit("Model check failed") - self.parent.communicate.statusBarUpdateSignal.emit("Model check failed") + # GuiUtils.communicator.statusBarUpdateSignal.emit("Model check failed") + GuiUtils.communicator.statusBarUpdateSignal.emit("Model check failed") # Format text box with error indicators self.txtFunction.setStyleSheet("border: 5px solid red") diff --git a/src/sas/qtgui/Utilities/ModelEditors/TabbedEditor/TabbedModelEditor.py b/src/sas/qtgui/Utilities/ModelEditors/TabbedEditor/TabbedModelEditor.py index 65d5ae54b0..35ff6087f8 100644 --- a/src/sas/qtgui/Utilities/ModelEditors/TabbedEditor/TabbedModelEditor.py +++ b/src/sas/qtgui/Utilities/ModelEditors/TabbedEditor/TabbedModelEditor.py @@ -410,11 +410,11 @@ def updateFromPlugin(self): self.setTabEdited(False) # Notify listeners - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() # Notify the user msg = "Custom model " + filename + " successfully created." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + GuiUtils.communicator.statusBarUpdateSignal.emit(msg) logger.info(msg) def createOrUpdateTab(self, filename: str | Path, widget: QtWidgets.QWidget): @@ -471,8 +471,8 @@ def findFirstError(self, full_path: str | Path) -> int: logger.error(traceback_to_show) # Set the status bar message - # GuiUtils.Communicate.statusBarUpdateSignal.emit("Model check failed") - self.parent.communicate.statusBarUpdateSignal.emit("Model check failed") + # GuiUtils.communicator.statusBarUpdateSignal.emit("Model check failed") + GuiUtils.communicator.statusBarUpdateSignal.emit("Model check failed") # Find all QTextBrowser and QCodeEditor children text_browsers = self.tabWidget.currentWidget().findChildren(QtWidgets.QTextBrowser) @@ -547,7 +547,7 @@ def updateFromEditor(self): self.setTabEdited(False) # Notify listeners, since the plugin name might have changed - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() if self.isWidgetInTab(self.tabWidget, self.plugin_widget): # Attempt to update the plugin widget with updated model information @@ -555,7 +555,7 @@ def updateFromEditor(self): # notify the user msg = f"{str(filename)} successfully saved." - self.parent.communicate.statusBarUpdateSignal.emit(msg) + GuiUtils.communicator.statusBarUpdateSignal.emit(msg) logger.info(msg) def noModelCheckWarning(self): diff --git a/src/sas/qtgui/Utilities/PluginManager.py b/src/sas/qtgui/Utilities/PluginManager.py index 21de87c837..ca6def6ded 100644 --- a/src/sas/qtgui/Utilities/PluginManager.py +++ b/src/sas/qtgui/Utilities/PluginManager.py @@ -59,7 +59,7 @@ def addSignals(self): self.cmdEdit.clicked.connect(self.onEdit) self.cmdHelp.clicked.connect(self.onHelp) self.lstModels.selectionModel().selectionChanged.connect(self.onSelectionChanged) - self.parent.communicate.customModelDirectoryChanged.connect(self.readModels) + GuiUtils.communicator.customModelDirectoryChanged.connect(self.readModels) def onSelectionChanged(self): """ @@ -96,7 +96,7 @@ def onDelete(self): name = os.path.join(find_plugins_dir(), plugin + ".py") os.remove(name) - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() def onAdd(self): """ @@ -162,7 +162,7 @@ def onAddFile(self): if os.path.isfile(c_file): copy(c_file, plugin_dir) - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() log_msg = "New plugin added: %s" % file_name logger.info(log_msg) @@ -190,7 +190,7 @@ def onDuplicate(self): logger.error("Could not find appropriate filename for " + src_file) dst_file = os.path.join(plugin_dir, dst_filename) copyfile(src_file, dst_file) - self.parent.communicate.customModelDirectoryChanged.emit() + GuiUtils.communicator.customModelDirectoryChanged.emit() def onEdit(self): """ diff --git a/src/sas/qtgui/Utilities/ResultPanel.py b/src/sas/qtgui/Utilities/ResultPanel.py index c822e2dfa7..bf9a972fe4 100644 --- a/src/sas/qtgui/Utilities/ResultPanel.py +++ b/src/sas/qtgui/Utilities/ResultPanel.py @@ -4,6 +4,8 @@ """ from PySide6 import QtCore, QtWidgets +from sas.qtgui.Utilities.GuiUtils import communicator + class ResultPanel(QtWidgets.QTabWidget): """ @@ -22,7 +24,7 @@ def __init__(self, parent, manager=None, *args, **kwargs): """ super(ResultPanel, self).__init__(parent) self.manager = manager - self.communicator = self.manager.communicator() + self.communicator = communicator self.setMinimumSize(400, 400) self.data_id = None diff --git a/src/sas/qtgui/Utilities/UnitTesting/AddMultEditorTest.py b/src/sas/qtgui/Utilities/UnitTesting/AddMultEditorTest.py index ad83bc1db7..692645a690 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/AddMultEditorTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/AddMultEditorTest.py @@ -5,7 +5,7 @@ import pytest from PySide6 import QtGui, QtWidgets -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator # Local from sas.qtgui.Utilities.ModelEditors.AddMultEditor.AddMultEditor import AddMultEditor @@ -19,7 +19,7 @@ def widget(self, qapp, mocker): '''Create/Destroy the AddMultEditor''' class dummy_manager: HELP_DIRECTORY_LOCATION = "html" - communicate = Communicate() + communicator = communicator _parent = QtWidgets.QDialog() # mock models from plugin folder diff --git a/src/sas/qtgui/Utilities/UnitTesting/FileConverterTest.py b/src/sas/qtgui/Utilities/UnitTesting/FileConverterTest.py index e7b529706e..79fe319ecd 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/FileConverterTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/FileConverterTest.py @@ -8,7 +8,7 @@ import sasdata.file_converter.FileConverterUtilities as Utilities from sas.qtgui.Utilities.FileConverter import FileConverterWidget -from sas.qtgui.Utilities.GuiUtils import Communicate +from sas.qtgui.Utilities.GuiUtils import communicator class FileConverterTest: @@ -18,7 +18,7 @@ class FileConverterTest: def widget(self, qapp): '''Create/Destroy the FileConverter''' class dummy_manager: - communicate = Communicate() + communicator = communicator() _parent = QtWidgets.QDialog() w = FileConverterWidget(dummy_manager()) diff --git a/src/sas/qtgui/Utilities/UnitTesting/GridPanelTest.py b/src/sas/qtgui/Utilities/UnitTesting/GridPanelTest.py index b75efbbd1e..5fac8c6c10 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/GridPanelTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/GridPanelTest.py @@ -27,9 +27,7 @@ def widget(self, qapp): class dummy_manager: _parent = QtWidgets.QWidget() def communicator(self): - return GuiUtils.Communicate() - def communicate(self): - return GuiUtils.Communicate() + return GuiUtils.communicator w = BatchOutputPanel(parent=dummy_manager(), output_data=self.output_for_test()) test_table = {"p1":[1,2,3], "p2":[4,5,None], @@ -103,8 +101,8 @@ def testActionLoadData(self, widget, mocker): def notestPlotFits(self, widget): '''Test plot generation from selected table rows''' # mock tested calls - #GuiUtils.Communicate.plot - spy_plot_signal = QtSignalSpy(widget.communicate, widget.communicate().plotFromNameSignal) + #GuiUtils.communicator.plot + spy_plot_signal = QtSignalSpy(widget.communicator, widget.communicator.plotFromNameSignal) # Select row #1 widget.tblParams.selectRow(0) QtWidgets.QApplication.processEvents() diff --git a/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py b/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py index 42d8ff1a94..00f1e8a75e 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/GuiUtilsTest.py @@ -35,11 +35,11 @@ def testGetAppDir(self): pass - def testCommunicate(self, qapp): + def testCommunicator(self, qapp): """ Test the container class with signal definitions """ - com = GuiUtils.Communicate() + com = GuiUtils.communicator # All defined signals list_of_signals = [ diff --git a/src/sas/qtgui/Utilities/UnitTesting/ReportDialogTest.py b/src/sas/qtgui/Utilities/UnitTesting/ReportDialogTest.py index 0f3b2020c4..9a89c5fbed 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/ReportDialogTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/ReportDialogTest.py @@ -25,9 +25,7 @@ def widget(self, qapp): class dummy_manager(QtWidgets.QWidget): _parent = QtWidgets.QWidget() def communicator(self): - return GuiUtils.Communicate() - def communicate(self): - return GuiUtils.Communicate() + return GuiUtils.communicator class dummy_report: html = "test_html" diff --git a/src/sas/qtgui/Utilities/UnitTesting/TabbedModelEditorTest.py b/src/sas/qtgui/Utilities/UnitTesting/TabbedModelEditorTest.py index 97cbb84acc..fe1c86c9eb 100644 --- a/src/sas/qtgui/Utilities/UnitTesting/TabbedModelEditorTest.py +++ b/src/sas/qtgui/Utilities/UnitTesting/TabbedModelEditorTest.py @@ -17,7 +17,7 @@ def widget(self, qapp, mocker): '''Create/Destroy the editor''' class dummy_manager: _parent = QWidget() - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator w = TabbedModelEditor(parent=dummy_manager) @@ -31,7 +31,7 @@ def widget_edit(self, qapp, mocker): '''Create/Destroy the editor''' class dummy_manager: _parent = QWidget() - communicate = GuiUtils.Communicate() + communicator = GuiUtils.communicator w = TabbedModelEditor(parent=dummy_manager, edit_only=True)