-1

I am trying to print a string after some delay in my sample program. The problem I am facing is, I am getting the first string immediately without delay and second string after the delay. What I am doing wrong? Please correct me. Here is my code:

import tkinter as tk
root = tk.Tk()
root.title("after method")
root.geometry("100x100")

def displayint():
    print("hello world")

def display():
    root.after(5000,displayint())
    root.after(10000,displayint())

button = tk.Button(root,text='press',command = display)
button.pack()

root.mainloop()
Rishit Dagli
  • 1,000
  • 8
  • 20
  • Does this answer your question? [tkinter: how to use after method](https://stackoverflow.com/a/25753719/7414759) – stovfl May 16 '20 at 16:22

2 Answers2

1

Remove the parenthesis following the call to displayint in the function display:

def display():
    root.after(5000,displayint)
    root.after(10000,displayint)
2earth
  • 45
  • 5
0

You should remove parentheses from displayint():

root.after(5000, displayint)
root.after(10000, displayint)
Alderven
  • 7,569
  • 5
  • 26
  • 38