How To Pass Changing/updating Data To Another Pop-up Window?
I got the following code for Python GUI. I found I cannot update the data running in the main window to the pop-up window. In this example I use some random data to mimic the video
Solution 1:
I did some changes to your power_window
class:
classpower_window(QMainWindow):
# this window has no parent. It will appear as a free-floating window as we want.def__init__(self,parent):
super().__init__()
self.setWindowTitle("Total power in the frame")
self.main_widget = QWidget()
self.main_layout = QGridLayout()
self.main_widget.setLayout(self.main_layout)
self.setCentralWidget(self.main_widget)
self.plot_plt = pg.PlotWidget() # this is our plot canvas
self.plot_plt.showGrid(x=True,y=True) # show grid
self.main_layout.addWidget(self.plot_plt, 1, 0, 3, 3)
# self.plot_plt.setYRange(max=100,min=0)
self.parent = parent
self.data_list = []
parent.timer.timeout.connect(self.plot_data) # update plot# parent.updateData.change.connect(self.plot_data) # not working, may need to use pyqtSignal for custom signals
self.plot_data()
defplot_data(self):
self.frame_sum_data = self.parent.updateData()
self.data_list.append(self.frame_sum_data)
self.plot_plt.plot().setData(self.data_list,pen='g') # change the color of the pen
I think the problem is because your program calls the updateData()
on the __init__
so it only gets the first value and never again updates that value.
Tell me if it does what you want.
Post a Comment for "How To Pass Changing/updating Data To Another Pop-up Window?"