I've been trying to get a controller to work with signals (pyqtSignal), but I get this message when interacting with the GUI:
Traceback (most recent call last):
File "main_signals.py", line 102, in <module>
helper.Sinal.Emt.connect(PID.Imprime, QtCore.Qt.QueuedConnection)
AttributeError: 'PyQt4.QtCore.pyqtBoundSignal' object has no attribute 'Emt'
Would someone please tell me what I'm doing wrong, here's the stripped down version of the code (main_signals.py):
# Import 3rd party libraries
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import QObject, pyqtSignal
import time
import pyqtgraph
# Import python standard modules
import sys
# This file holds the MainWindow
import Plotter
# Variables
T = [0]
R = [0]
# Disregard this function
def ReadChannel(channel):
# -----------------------------------------------------------------
class Ctrldr(QtGui.QMainWindow, Plotter.Ui_MainWindow):
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.QOutput.clicked.connect(self.Calculo)
# Plotting
@QtCore.pyqtSlot(str, tuple)
def Imprime(self, name, ptm):
global T, R, W
x, y = ptm
R.append(y)
self.graphicsView.plotItem.plot(T, R, pen='b')
# Calculations
def Calculo(self):
global T
t = time.clock()
T.append(t)
Read = ReadChannel(0)
Helper.Sinal.emit("Sensor", (t, Read))
Read = str(Read)
self.QResult.setText(Read)
# -----------------------------------------------------------------
class Helper(QtCore.QObject):
Sinal = QtCore.pyqtSignal(str, tuple)
def __init__(self):
super(self.__class__, self).__init__()
def Emt(self, str, tuple):
self.Sinal.emit(str, tuple)
# -----------------------------------------------------------------
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
PID = Ctrldr()
helper = Helper()
helper.Sinal.connect(PID.Imprime)
PID.show()
app.exec_()
Tried to follow the examples in these 2 pages: