Эх сурвалжийг харах

oops dragging nodes didn't work after adding recorded temperatures...

Bengt Sjölén 3 сар өмнө
parent
commit
58a4de4b10

+ 16 - 13
pc410/src/main/python/main.py

@@ -1,4 +1,6 @@
-#from fbs_runtime.application_context.PyQt5 import ApplicationContext
+usefbs=0
+if usefbs:
+    from fbs_runtime.application_context.PyQt5 import ApplicationContext
 from PyQt5.QtCore import QRunnable,pyqtSlot,QThreadPool,QMetaObject,Qt,Q_ARG,QTimer,QTime,QProcess,QItemSelection,QItemSelectionModel,QSignalBlocker,QRectF,pyqtSignal
 from PyQt5.QtWidgets import (QMainWindow, QApplication, QWidget, QPushButton, QStackedLayout,QItemDelegate,
                              QSlider,
@@ -178,19 +180,20 @@ class SimplifiedPlotItemMovement(pg.PlotItem):
             local_pos = self.vb.mapSceneToView(pos)
 
             for item in self.dataItems:
-                new_pts = item.scatter.pointsAt(local_pos)
-                if len(new_pts) == 1:
-                    # Store the drag point and the index of the point for future reference.
-                    self.dragPoint = new_pts[0]
-                    self.dragIndex = item.scatter.points().tolist().index(new_pts[0])
-                    # Find the initial offset of the drag operation from the current point.
-                    # This value should allow for the initial mismatch from cursor to point to be accounted for.
+                if hasattr(item,"scatter"):
+                    new_pts = item.scatter.pointsAt(local_pos)
+                    if len(new_pts) == 1:
+                        # Store the drag point and the index of the point for future reference.
+                        self.dragPoint = new_pts[0]
+                        self.dragIndex = item.scatter.points().tolist().index(new_pts[0])
+                        # Find the initial offset of the drag operation from the current point.
+                        # This value should allow for the initial mismatch from cursor to point to be accounted for.
 
-                    self.dragOffset = new_pts[0].pos() - local_pos
-                    # If we get here, accept the event to prevent the screen from panning during the drag.
+                        self.dragOffset = new_pts[0].pos() - local_pos
+                        # If we get here, accept the event to prevent the screen from panning during the drag.
 
-                    
-                    ev.accept()
+
+                        ev.accept()
         elif ev.isFinish():
             # The drag is finished. Reset the drag point and index.
             self.dragPoint = None
@@ -1008,7 +1011,7 @@ class MainWindow(QMainWindow):
 
         
 if __name__ == '__main__':
-    if 0:
+    if usefbs:
         # run with fbs ie fbs run etc
         appctxt = ApplicationContext()       # 1. Instantiate ApplicationContext
         app=appctxt.app