Apr-28-2022, 06:18 PM
(This post was last modified: Apr-28-2022, 06:18 PM by deanhystad.)
Please wrap code in Python tags.
app.exec_() blocks program execution until the GUI is closed.
sys.exit(app.exec_()) exits the program as soon as this happens.
This is never executed:
Using a sleep(0.4) to prevent a button press from being counted as multiple presses is not reliable. You never want to use the sleep() command in a gui application. It makes the GUI unresponsive.
app.exec_() blocks program execution until the GUI is closed.
sys.exit(app.exec_()) exits the program as soon as this happens.
This is never executed:
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 = 0Read up on QTimer to see how you can run your GUI and run your hardware code simultaneously.
Using a sleep(0.4) to prevent a button press from being counted as multiple presses is not reliable. You never want to use the sleep() command in a gui application. It makes the GUI unresponsive.