Tkinter ব্যবহার করে, আমরা GUI তৈরি করতে পারি যা স্বয়ংক্রিয় আপডেটের জন্য কনফিগার করা যেতে পারে। এই উদ্দেশ্যে, আমরা GUI-ভিত্তিক ঘড়ি তৈরি করব যা সময় পরিবর্তন হলে স্বয়ংক্রিয়ভাবে রিফ্রেশ হয়ে যাবে। আমরা দিন এবং টাইমজোনের সাথে ঘড়িটি প্রদর্শন করব।
প্রথমে, আমরা নোটবুকে tkinter লাইব্রেরি আমদানি করব, তারপর আমরা একটি ফাংশন তৈরি করব যা “strftime” ব্যবহার করে বর্তমান সময় ও দিনের উদাহরণ তৈরি করে। ফাংশন।
উদাহরণ
#Import the tkinter library
from tkinter import *
import time
#Create an instance of the canvas
win = Tk()
#Select the title of the window
win.title("tutorialspoint.com")
#Define the geometry of the window
win.geometry("600x400")
#Define the clock which
def clock():
hh= time.strftime("%I")
mm= time.strftime("%M")
ss= time.strftime("%S")
day=time.strftime("%A")
ap=time.strftime("%p")
time_zone= time.strftime("%Z")
my_lab.config(text= hh + ":" + mm +":" + ss)
my_lab.after(1000,clock)
my_lab1.config(text=time_zone+" "+ day)
#Update the Time
def updateTime():
my_lab.config(text= "New Text")
#Creating the label with text property of the clock
my_lab= Label(win,text= "",font=("sans-serif", 56), fg= "red")
my_lab.pack(pady=20)
my_lab1= Label(win, text= "", font=("Helvetica",20), fg= "blue")
my_lab1.pack(pady= 10)
#Calling the clock function
clock()
#Keep Running the window
win.mainloop() আউটপুট
উপরের কোডটি চালানোর ফলে উইন্ডোতে একটি স্বয়ংক্রিয়ভাবে আপডেট হওয়া GUI অ্যাপ্লিকেশন তৈরি হবে৷
৷ 