Hello All,
I am creating a GUI that takes input from the user and then executes one of several "if" statements which not only places the relevant text on the tkinter label, but also execute other files and print statements.
For one of those "if" statements, after displaying the relevant text (in this case it regarding an incorrect PIN) I then need it to wait 20
seconds for user input and then place another set of text (the same text that was displayed when the program was started).
I am trying to use after() within the "if" statement but I can't get it to work. I also tried creating a function that I call from within the "if" statement
and while this executes, it completely ignores the original text from within the "if" statement, directly executes the text from the function and doesn't even notice the after().
it looks something like the below ("infopad" is the label displaying messages to the user):
I have tried many ways to do this and this was simply the most recent but of course, all failed. Note that time.sleep() isn't ideal here as my GUI has animation and it pauses everything.
Please let me know if you can help.
I am creating a GUI that takes input from the user and then executes one of several "if" statements which not only places the relevant text on the tkinter label, but also execute other files and print statements.
For one of those "if" statements, after displaying the relevant text (in this case it regarding an incorrect PIN) I then need it to wait 20
seconds for user input and then place another set of text (the same text that was displayed when the program was started).
I am trying to use after() within the "if" statement but I can't get it to work. I also tried creating a function that I call from within the "if" statement
and while this executes, it completely ignores the original text from within the "if" statement, directly executes the text from the function and doesn't even notice the after().
it looks something like the below ("infopad" is the label displaying messages to the user):
Code:
else: #text telling the user it is incorrect infopad['text'] = "Unfortunately, that PIN is incorrect" #calling the function to change the label text update_label(infopad)#the function external to the "if" statements with the delay and then the new label text (the content of the new text is just for me for the #moment to see it is working before I put the full correct text)def update_label(infopad): new_text = "20 SECONDS IS UP" infopad.after(20000, update_label, infopad) infopad.configure(text=new_text) I have tried many ways to do this and this was simply the most recent but of course, all failed. Note that time.sleep() isn't ideal here as my GUI has animation and it pauses everything.
Please let me know if you can help.
Statistics: Posted by Furutsu — Sun Nov 16, 2025 3:53 pm