25 lines
660 B
Python
25 lines
660 B
Python
from tkinter import *
|
|
import time
|
|
from random import randint
|
|
import threading
|
|
|
|
def five_seconds():
|
|
time.sleep(5)
|
|
my_label.config(text="5 sec up")
|
|
|
|
def rando():
|
|
rand_label.config(text=f'Random number {randint(1,100)}')
|
|
|
|
root = Tk()
|
|
root.title("Jfs Threading Starts !!")
|
|
root.geometry("500x300+200+200")
|
|
my_label = Label(root,text="Hello there")
|
|
my_label.pack(pady=20)
|
|
my_button = Button(root,text="5 sec",command=threading.Thread(target=five_seconds).start())
|
|
my_button.pack(pady=20)
|
|
my_button2 = Button(root,text="Pick random number",command=rando)
|
|
my_button2.pack(pady=20)
|
|
rand_label = Label(root,text="")
|
|
rand_label.pack(pady=20)
|
|
|
|
root.mainloop() |