better add_new_desc_to_list; fixed multi plots with marked image; typo

This commit is contained in:
2023-04-14 17:57:33 +02:00
parent 7470f1388b
commit da8d7b0a2b

View File

@ -109,7 +109,7 @@ class MainWindow(QMainWindow):
The configuration is forwarded to the constructor of PlotDescription.
Allowed keys are: title, xlabel, ylabel, xs, ys.
"""
desc = self.add_new_desc_to_list(name, cfg)
desc = self.add_new_desc_to_list(PlotDescription, name, cfg)
if self.menu_settings.checkboxes["Open new plots"].isChecked():
if not self.mdi.findSubWindow(name):
self.sig_make_new_plot.emit(name, desc)
@ -150,7 +150,7 @@ class MainWindow(QMainWindow):
The configuration is forwarded to the constructor of ImageDescription.
Allowed keys are: title, xlabel, ylabel, image.
"""
desc = self.add_new_desc_to_list(name, cfg, Desc=ImageDescription) #TODO: clean up Desc argument
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:
@ -209,8 +209,8 @@ class MainWindow(QMainWindow):
for fn in fns:
data = read_dict(fn)
for k, v in data.items():
Desc = ImageDescription if "image" in v else PlotDescription #TODO
self.add_new_desc_to_list(k, v, Desc=Desc)
DescType = ImageDescription if "image" in v else PlotDescription #TODO
self.add_new_desc_to_list(DescType, k, v)
def on_file_save(self):
@ -228,8 +228,8 @@ class MainWindow(QMainWindow):
# Plumbing
def add_new_desc_to_list(self, name, cfg, Desc=PlotDescription): #TODO
desc = Desc(name, **cfg)
def add_new_desc_to_list(self, DescType, name, cfg):
desc = DescType(name, **cfg)
self.lst.set(name, desc)
return desc
@ -255,13 +255,14 @@ class MainWindow(QMainWindow):
for i in items:
i.timestamps.access.update()
i.set_alarm(False)
items = (i for i in items if isinstance(i.value, PlotDescription)) #TODO
descs = {i.key: i.value for i in items}
names = descs.keys()
name = " | ".join(names)
self.activate_or_make_subwin(MDISubMultiPlot, name, descs)
#TODO: the following two could be methods to MDIArea?
#TODO: the following two could be methods of MDIArea?
def activate_or_make_subwin(self, MDISubType, name, *args, **kwargs):
sub = self.mdi.findSubWindow(name)