random number and tkinter not working
Question: i'm new to python as i've only used it for 4 months, im trying to program a
tkinter window in which a label displays a random number ever second i have
this so far:

    
    
    from tkinter import *
    from random import *
    testy = "0"
    root = Tk()
    lbl = Label(root,text="0")
    
    def callback():
        global testy
        lbl.configure(text=testy)
        testy = str(randint(0,10))
        root.after(2000,callback)
    lbl.pack()
    root.after(2000,callback)
    root.mainloop()
    

any help is apprieciated


Answer: Yours seems to work for me, this is a slightly more condensed version however
which is called every 1 second instead of 2, as that is what you outlined
wanting in your question.

    
    
    from tkinter import *
    import random
    
    root = Tk()
    lbl = Label(root)
    lbl.pack()
    
    def replace_text():
        lbl.config(text=str(random.random()))
        root.after(1000, replace_text)
    
    replace_text()
    root.mainloop()
    

