added and use MDIArea.findSubWindow

This commit is contained in:
2022-12-19 13:38:54 +01:00
parent 7f4a2386f9
commit 03beb10c4b
2 changed files with 18 additions and 17 deletions

View File

@ -44,30 +44,25 @@ class MainWindow(QMainWindow):
def new_plot(self, name, cfg):
desc = PlotDescription(**cfg)
self.lst.add(name, desc)
for sub in self.mdi.subWindowList():
if sub.windowTitle() == name:
return
self.sig_make_new_plot.emit(name, desc)
if not self.mdi.findSubWindow(name):
self.sig_make_new_plot.emit(name, desc)
def append_data(self, name, point):
lst = self.lst
lst.append(name, point)
for sub in self.mdi.subWindowList():
if sub.windowTitle() == name:
desc = lst.data[name]
sub.plot.setData(*desc.data)
self.lst.append(name, point)
sub = self.mdi.findSubWindow(name)
if sub:
desc = self.lst.data[name]
sub.plot.setData(*desc.data)
def on_select_list_item(self, index):
name, desc = self.lst.get(index)
for sub in self.mdi.subWindowList():
if sub.windowTitle() == name:
self.mdi.setActiveSubWindow(sub)
return
self.on_make_new_plot(name, desc)
sub = self.mdi.findSubWindow(name)
if sub:
self.mdi.setActiveSubWindow(sub)
else:
self.on_make_new_plot(name, desc)
def on_make_new_plot(self, *args, **kwargs):

6
mdi.py
View File

@ -62,6 +62,12 @@ class MDIArea(QMdiArea):
painter.end()
def findSubWindow(self, name):
for sub in self.subWindowList():
if sub.windowTitle() == name:
return sub
class MDISubPlot(QMdiSubWindow):