[communicator] add signal for plotting errors and use it

This commit is contained in:
Jan Grewe 2021-01-18 10:35:48 +01:00
parent b68f8bbc7a
commit c8fe616c44
3 changed files with 30 additions and 24 deletions

View File

@ -9,4 +9,6 @@ class Communicate(QObject):
item_selected = pyqtSignal(NixTreeItem)
plot_error = pyqtSignal(str)
communicator = Communicate()

View File

@ -1,7 +1,6 @@
import os
import sys
from PyQt5.QtWidgets import QWidget, QFileDialog, QMainWindow, QMenuBar, QToolBar, QAction, QStatusBar, QSizePolicy
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtGui import QKeySequence
from PyQt5.QtCore import QSize, QSettings, Qt
from nixview.util.file_handler import FileHandler, NodeType
@ -30,6 +29,7 @@ class NixView(QMainWindow):
comm.communicator.open_recent.connect(self.on_open_recent)
comm.communicator.item_selected.connect(self.on_item_selected)
comm.communicator.plot_error.connect(self.on_plot_error)
self.show()
def on_open_recent(self, event):
@ -167,6 +167,9 @@ class NixView(QMainWindow):
if self._current_item is not None:
self._cw.plot_item(self._current_item.node_descriptor)
def on_plot_error(self, s):
self.statusBar().showMessage(s, 5000)
def on_about(self, e):
about = AboutDialog(self)
about.show()

View File

@ -11,6 +11,7 @@ from matplotlib.widgets import Slider
from nixview.util.file_handler import FileHandler
from nixview.util.dataview import DataView
from nixview.communicator import communicator
def create_label(entity):
@ -347,9 +348,9 @@ class PlotScreen(QWidget):
try:
self._data_view = DataView(item, self._file_handler)
except ValueError as e:
print("error in plotscreen.plot", e)
communicator.plot_error.emit("error in plotscreen.plot %s" % e)
return
self._data_view.request_more() # TODO this is just a test, needs to be removed
print(self._data_view)