diff --git a/grum/mainwin.py b/grum/mainwin.py index 652d669..a37de16 100644 --- a/grum/mainwin.py +++ b/grum/mainwin.py @@ -2,7 +2,7 @@ from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtWidgets import QMainWindow, QSplitter from . import assets -from .descs import DESC_TYPES, Description, PlotDescription, ImageDescription +from .descs import DESC_TYPES, Description, ImageDescription, PlotDescription from .dictlist import DictList from .exampledata import exampledata from .h5filedlg import open_h5_files_dialog, save_h5_file_dialog @@ -90,11 +90,11 @@ class MainWindow(QMainWindow): if not offline: self.rst = rst = RPCServerThread(host, port, doc_title_suffix=title) rst.start() + rst.server.register_function(self.new_image) rst.server.register_function(self.new_plot) rst.server.register_function(self.append_data) rst.server.register_function(self.extend_data) rst.server.register_function(self.set_data) - rst.server.register_function(self.new_image) self.sig_make_new_subwin.connect(self.on_make_new_subwin) @@ -106,6 +106,20 @@ class MainWindow(QMainWindow): # Remote API calls + def new_image(self, name, cfg): + """ + Create a new image using the configuration dict . + The configuration is forwarded to the constructor of ImageDescription. + Allowed keys are: title, xlabel, ylabel, image. + """ + desc = self.add_new_desc_to_list(ImageDescription, name, cfg) + if self.menu_settings.checkboxes["Open new plots"].isChecked(): + sub = self.mdi.findSubWindow(name) + if sub: + sub.pw.setImage(desc.data) #TODO lacks the list sync + else: + self.sig_make_new_subwin.emit(name, desc) + def new_plot(self, name, cfg): """ Create a new plot using the configuration dict . @@ -147,20 +161,6 @@ class MainWindow(QMainWindow): desc.data = data self.sync_item_and_plots(item) - def new_image(self, name, cfg): - """ - Create a new image using the configuration dict . - The configuration is forwarded to the constructor of ImageDescription. - Allowed keys are: title, xlabel, ylabel, image. - """ - desc = self.add_new_desc_to_list(ImageDescription, name, cfg) - if self.menu_settings.checkboxes["Open new plots"].isChecked(): - sub = self.mdi.findSubWindow(name) - if sub: - sub.pw.setImage(desc.data) #TODO lacks the list sync - else: - self.sig_make_new_subwin.emit(name, desc) - # Signal callbacks