Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> Python

Tkinter का उपयोग करके Automatically Updating GUI कैसे बनाएं?

Tkinter का उपयोग करके, हम GUI बना सकते हैं जिसे auto-updation के लिए configure किया जा सकता है। इस उद्देश्य के लिए, हम GUI-based clocks बनाएंगे जो time बदलने पर automatically refresh हो जाएंगे। हम clock को day और TimeZone के साथ display करेंगे।

पहले, हम notebook में tkinter library import करेंगे, फिर हम एक function बनाएंगे जो "strftime" फंक्शन का उपयोग करके current time और day के instances बनाता है।

उदाहरण

# 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()

आउटपुट

उपरोक्त code चलाने से window में automatically updated GUI Application बनेगा।

Tkinter का उपयोग करके Automatically Updating GUI कैसे बनाएं?

  1. Tkinter का उपयोग करके Splash Screen कैसे बनाएं? Tkinter का उपयोग करके Splash Screen कैसे बनाएं?

    मान लीजिए हम tkinter का उपयोग करके splash screen बनाना चाहते हैं। Splash screen बनाने के लिए, हम नीचे दिए गए steps का पालन करेंगे: कुछ labels के साथ splash screen बनाएं। overrideredirect method का उपयोग करके splash screen को borderless बनाएं। मुख्य window के लिए एक function बनाएं जो splash screen क

  1. Python में tkinter का उपयोग करके सिंपल GUI कैलकुलेटर कैसे बनाएं? Python में tkinter का उपयोग करके सिंपल GUI कैलकुलेटर कैसे बनाएं?

    परिचय Python में, हम GUI कंपोनेंट्स बनाने और बेहतर यूजर इंटरफेस तैयार करने के लिए tkinter लाइब्रेरी का उपयोग करते हैं। इस लेख में आप सिंपल GUI आधारित कैलकुलेटर एप्लिकेशन बनाने के मेथड्स सीखेंगे। शुरुआत करना इसमें कूदने से पहले, कुछ चीजें हैं जिन्हें हमें पहले व्यवस्थित करने की आवश्यकता है। आइए Pyth

  1. Python में Tkinter का उपयोग करके डिजिटल घड़ी बनाना Python में Tkinter का उपयोग करके डिजिटल घड़ी बनाना

    Python Tkinter का उपयोग वेब और डेस्कटॉप के लिए सभी प्रकार के GUI प्रोग्राम बनाने के लिए किया जा सकता है। इस लेख में हम देखेंगे कि घंटे, मिनट और सेकंड लाइव प्रदर्शित करने वाली डिजिटल घड़ी कैसे बनाई जाए। हम समय को घंटे, मिनट और सेकंड प्रारूप में प्रदर्शित करने वाली विधि strftime को आयात करने के लिए ti