I have a PyQt Gui application that has multiple QDialog windows that I use to plot data using matplotlib widget. This is the code I'm using is below.
Only one emitted signal is caught. Which ever QDialog is created last catches it's emitted signal. If the TempBox
dialog is created last the NewTemp_signal
is caught, or if the RealBox
dialog is created last the NewReal_signal
is caught. But, the other signal is not caught. How do I catch both signals to update all dialogs? Thanks
Dialog window class
class GUIgraph(QtGui.QDialog):
def __init__(self,parent=None):
QtGui.QDialog.__init__(self,parent)
print 'This is the Histograph dialog class function'
self.graph = Ui_histogram_Dialog()
self.graph.setupUi(self)
Functions that create new windwos
def TempgraphFunc(self):
QtGui.QWidget.__init__(self,parent=None)
self.TempBox = GUIgraph()
self.TempBox.setWindowTitle("Temperature")
self.NewTemp_signal.connect(self.TempPlotFunc)
self.TempBox.show()
def RealgraphFunc(self):
QtGui.QWidget.__init__(self,parent=None)
self.RealBox = GUIgraph()
self.RealBox.setWindowTitle("Real Space")
self.NewReal_signal.connect(self.RealPlotFunc)
print 'Real is connected'
self.RealBox.show()
In another function I emit a signal
def loadFiles(self):
....
self.NewTemp_signal.emit()
self.NewReal_signal.emit()
print ' signals emitted'
I think you have architectural problems. I don't see all your code, but at least this is very strange:
def TempgraphFunc(self):
QtGui.QWidget.__init__(self,parent=None)
self.TempBox = GUIgraph()
self.TempBox.setWindowTitle("Temperature")
self.NewTemp_signal.connect(self.TempPlotFunc)
self.TempBox.show()
In a method you are calling QtGui.QWidget.__init__
??? __init__
is the parent 'constructor' method, and you are supposed to call it from a subclass overridden __init__
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.