I am getting this error from my code:
RuntimeWarning: MetaObjectBuilder::addMethod: Invalid method signature provided for "CPU_VALUE"
self.threadclass.CPU_VALUE.connect(SIGNAL('CPU_VALUE'), self.UpdateProgressBar)
from PySide2 import QtWidgets, QtCore
from PySide2.QtCore import SIGNAL, Signal
import main
import sysinfo
class MainUiClass(main.Ui_MainWindow, QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainUiClass, self).__init__(parent)
self.setupUi(self)
self.threadclass = ThreadClass()
self.threadclass.start()
self.threadclass.CPU_VALUE.connect(SIGNAL('CPU_VALUE'), self.UpdateProgressBar)
# self.UpdateProgressBar()
def UpdateProgressBar(self):
val = sysinfo.getCPU()
self.progressBar.setValue(val)
class CpuClass(QtCore.QObject):
cpu = Signal()
class ThreadClass(QtCore.QThread):
CPU_VALUE = CpuClass()
cpu = Signal()
def __init__(self, parent=None):
super(ThreadClass, self).__init__(parent)
def run(self):
while 1:
# val = sysinfo.getCPU()
self.CPU_VALUE.emit(SIGNAL('CPU_VALUE'), sysinfo.getCPU())
# print(val)
if __name__ == '__main__':
app = QtWidgets.QApplication([])
a = MainUiClass()
a.show()
app.exec_()
sysinfo file:
import psutil
def getCPU():
return psutil.cpu_percent(interval=1)