Hello to all forum members. I'm just learning python and I decided to create a graphical window and in the second thread the displayed values in the console. Displaying values in the graphics window works fine, but not in the console anymore. The initially loaded value is constantly displayed to me, although in the graphics window I change it to the button buttons. When I would like to display the variable c on the lcd2 display in the graphics window, however, I don't know where I must put the code to display c. Below is the program code, displaying the value on lcd1 which changes with the buttons.
Thank you in advance for any help.
from PyQt5 import QtCore, QtGui, QtWidgets import threading import time variable1=20 variable2=40 class test(object): class Ui_MainWindow(object): def plus (self): self.variable1 += 1 self.lcdNumber.display(self.variable1) def minus (self): self.variable1 -= 1 self.lcdNumber.display(self.variable1) def setupUi(self, MainWindow): self.variable1=variable1 test.variable1=self.variable1 MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.lcdNumber = QtWidgets.QLCDNumber(self.centralwidget) self.lcdNumber.setGeometry(QtCore.QRect(60, 60, 64, 23)) self.lcdNumber.setObjectName("lcdNumber") self.lcdNumber_2 = QtWidgets.QLCDNumber(self.centralwidget) self.lcdNumber_2.setGeometry(QtCore.QRect(60, 120, 64, 23)) self.lcdNumber_2.setObjectName("lcdNumber_2") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(210, 60, 85, 23)) self.pushButton.pressed.connect(self.minus) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(330, 60, 85, 23)) self.pushButton_2.pressed.connect(self.plus) self.pushButton_2.setObjectName("pushButton_2") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.pushButton.setText(_translate("MainWindow", "-")) self.pushButton_2.setText(_translate("MainWindow", "+")) def worker(): while True: print(test.variable1) c= variable2 + 1 print(c) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = test.Ui_MainWindow() ui.setupUi(MainWindow) w = threading.Thread(name='worker', target=worker) w.start() MainWindow.show() sys.exit(app.exec_())Would anyone be able to tell me how to display the current value of variable1 in the console and where to insert the code to display the variable c in 2 lcd?
Thank you in advance for any help.