What I am trying to accomplish: Change the value of the progressbars on my GUI that is running on a thread. This value would be calculated outside the thread.
My question: How can I call the function defined under the class of the UI from my main? When I try to call it through Ui.updateProgressBar()
I get updateProgressBar() missing 1 required positional argument: 'self'
This is my code:
import PyQt5.QtWidgets
from PyQt5 import QtWidgets, uic
import pbl3_rc
import sys
import threading
class Ui(QtWidgets.QMainWindow):
def __init__(self):
super(Ui, self).__init__()__init__
uic.loadUi('PBL3_designer.ui', self)
self.prog_bar_cinza1 = self.findChild(PyQt5.QtWidgets.QProgressBar, 'progbar_set_cinza1')
self.prog_bar_cinza2 = self.findChild(PyQt5.QtWidgets.QProgressBar, 'progbar_set_cinza2')
self.prog_bar_cores1 = self.findChild(PyQt5.QtWidgets.QProgressBar, 'progbar_set_cores1')
self.updateProgressBar()
self.show()
def updateProgressBar(self):
self.prog_bar_cinza1.setValue(val)
self.prog_bar_cinza2.setValue(val*2)
self.prog_bar_cores1.setValue(val*3)
def interface():
app = QtWidgets.QApplication(sys.argv)
ex = Ui()
app.exec_()
for i in range(5):
val += 1
print(val)
t = threading.Thread(target=interface)
t.daemon = True
t.start()
for i in range(5):
val += 1
print(val)
Ui.updateProgressBar()