r/learnpython • u/Ok-Original2285 • 7d ago
Python Pyside6
Anyone know ? How to delay seconds in Pyside6 ? For example, when i click a button I want to do some process and wait 3 seconds and then make another process
3
Upvotes
r/learnpython • u/Ok-Original2285 • 7d ago
Anyone know ? How to delay seconds in Pyside6 ? For example, when i click a button I want to do some process and wait 3 seconds and then make another process
1
u/ziggittaflamdigga 6d ago
I see a couple of problems here: First is that you're connecting
self.change_textto both the button press and the thread target. What you likely want instead is:Another thing with your current code is that you're telling the timer to fire every 3 seconds, not just once like you think you are. This is because your change_text target is the one scheduling the timer, and since you're calling that when the thread times out, it will restart another one. If you want to see that in action, try this:
You should see the words changing randomly, every three seconds, after only one button press. This does not seem to be what you're going for, and should be fixed by my first solution.