started to add plotting multiple selected entries together

This commit is contained in:
2023-01-07 00:33:01 +01:00
parent 2bd07dcbff
commit 1d22b8dace
3 changed files with 34 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from PyQt5.QtWidgets import QMainWindow, QSplitter
from . import assets
from .dictlist import DictList
from .mdi import MDIArea, MDISubPlot
from .mdi import MDIArea, MDISubPlot, MDISubMultiPlot
from .rpc import RPCServerThread
from .plotdesc import PlotDescription
from .menus import BarMenu
@ -29,6 +29,10 @@ class MainWindow(QMainWindow):
self.menu_settings = menu = BarMenu(bar, "&Settings")
menu.addCheckbox("Open new plots", state=True)
#TODO: where should this be? right click menu of the list?
self.menu_plot = menu = BarMenu(bar, "Plot")
menu.addAction("Plot selected", self.on_plot_selected)
self.mdi = mdi = MDIArea(bar)
splitter = QSplitter(Qt.Horizontal)
@ -82,4 +86,12 @@ class MainWindow(QMainWindow):
self.mdi.add(sub)
def on_plot_selected(self):
selected = self.lst.selectedItems()
pairs = ((i.key, i.value) for i in selected)
names, descs = zip(*pairs)
sub = MDISubMultiPlot(names, descs)
self.mdi.add(sub)

View File

@ -1,5 +1,5 @@
from .mdiarea import MDIArea
from .mdisubplot import MDISubPlot
from .mdisubplot import MDISubPlot, MDISubMultiPlot

View File

@ -28,3 +28,23 @@ class MDISubPlot(QMdiSubWindow):
#TODO
class MDISubMultiPlot(MDISubPlot):
def __init__(self, titles, descs, *args, **kwargs):
title = " | ".join(titles)
#TODO
QMdiSubWindow.__init__(self, *args, **kwargs)
self.setWindowTitle(title)
self.setWindowIcon(assets.char())
# without this, the SubWindow is not removed from the subWindowList
self.setAttribute(Qt.WA_DeleteOnClose)
plt = pg.PlotWidget()
self.plots = [d.make_plot(plt) for d in descs]
self.setWidget(plt)