Hello!
Im a totally newbie at this (as you will notice), but i am trying to use a Raspberry Pi and a TV-screen to make a scoreboard for my shuffleboard.
I've used QT-designer to make GUI, and gpiozero to make a scorecounter. Each of them are working alone, but when im trying to put them together noting happens ( the GUI pops up, but i cant change the values in the LCD numbers) It should work like this: I have three physical buttons, when i press button1 it should add a point for team number1, when i press button3 it should add a point for team number2 and when i press button2 it should reset both counters.
My code looks like this: Does anyone have tips to what im doing wrong?
Im a totally newbie at this (as you will notice), but i am trying to use a Raspberry Pi and a TV-screen to make a scoreboard for my shuffleboard.
I've used QT-designer to make GUI, and gpiozero to make a scorecounter. Each of them are working alone, but when im trying to put them together noting happens ( the GUI pops up, but i cant change the values in the LCD numbers) It should work like this: I have three physical buttons, when i press button1 it should add a point for team number1, when i press button3 it should add a point for team number2 and when i press button2 it should reset both counters.
My code looks like this: Does anyone have tips to what im doing wrong?
from gpiozero import Button from time import sleep from PyQt5 import QtCore, QtGui, QtWidgets count = 0 count1 = 0 class Ui_MainWindow(object): def setupUi(self, MainWindow): 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, 240, 121, 111)) self.lcdNumber.setObjectName("lcdNumber") self.lcdNumber_2 = QtWidgets.QLCDNumber(self.centralWidget) self.lcdNumber_2.setGeometry(QtCore.QRect(620, 240, 121, 111)) self.lcdNumber_2.setObjectName("lcdNumber_2") self.label = QtWidgets.QLabel(self.centralWidget) self.label.setGeometry(QtCore.QRect(7, 11, 791, 581)) self.label.setText("") self.label.setPixmap(QtGui.QPixmap("../Pictures/ulven.jpg")) self.label.setScaledContents(True) self.label.setObjectName("label") self.label.raise_() self.lcdNumber.raise_() self.lcdNumber_2.raise_() MainWindow.setCentralWidget(self.centralWidget) self.lcdNumber.display(count) self.lcdNumber_2.display(count1) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) button1 = Button(2) button2 = Button(3) button3 = Button(4) while True: if button3.is_pressed: count += 1 sleep(0.4) if button1.is_pressed: count1 += 1 sleep(0.4) elif button2.is_pressed: count = 0 count1 = 0
Larz60+ write Apr-28-2022, 06:33 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.