much simpler two-step logic

This commit is contained in:
2022-12-19 13:09:30 +01:00
parent 1c4f08331e
commit 48e0c35c4f

View File

@ -35,31 +35,26 @@ class MainWindow(QMainWindow):
rst = RPCServerThread("localhost", 8000) rst = RPCServerThread("localhost", 8000)
rst.start() rst.start()
rst.server.register_function(self.append) rst.server.register_function(self.new_plot)
rst.server.register_function(self.append_data)
self.sig_make_new_plot.connect(self.make_new_plot) self.sig_make_new_plot.connect(self.make_new_plot)
def append(self, name, xy): def new_plot(self, name, cfg):
pd = PlotDescription(title=name) pd = PlotDescription(**cfg)
x, y, pd.xlabel, pd.ylabel = xy self.lst.add(name, pd)
self.sig_make_new_plot.emit(name, pd)
def append_data(self, name, xy):
lst = self.lst lst = self.lst
show_it = (name not in lst.data) lst.append(name, xy)
if show_it:
lst.add(name, pd)
lst.append(name, (x, y))
for sub in self.mdi.subWindowList(): for sub in self.mdi.subWindowList():
if sub.windowTitle() == name: if sub.windowTitle() == name:
pd = lst.data[name] pd = lst.data[name]
sub.plot.setData(pd.xs, pd.ys) sub.plot.setData(pd.xs, pd.ys)
if show_it:
pd = lst.data[name]
self.sig_make_new_plot.emit(name, pd)
def on_select_list_item(self, index): def on_select_list_item(self, index):
key, value = self.lst.get(index) key, value = self.lst.get(index)