0

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' 
JMD
  • 405
  • 1
  • 9
  • 17

1 Answers1

0

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__

warvariuc
  • 57,116
  • 41
  • 173
  • 227
  • removing the `__init__` function fixed the problem. I gotta say that I don't completely understand everything I write (copy and paste). I normally try to find code snippets that do what I want and then modify them to suite my needs. I'm not sure why I had the constructor method. – JMD Mar 22 '13 at 15:39
  • 1
    > removing the `__init__` function fixed the problem < I think you mean 'removing the call to `__init__` method. Glad you fixed it. But you have to understand what you are doing. Read more about [Python, Object Oriented Programming](http://www.diveintopython.net/object_oriented_framework/defining_classes.html#d0e11720), etc. And don't forget to upvote/accept good answers to your questions. Cheers! – warvariuc Mar 23 '13 at 05:50