टिंकर एक पायथन लाइब्रेरी है जिसका उपयोग जीयूआई-आधारित एप्लिकेशन बनाने और विकसित करने के लिए किया जाता है। मान लीजिए कि हमें एक ऐसा एप्लिकेशन बनाना है जिससे हम विजेट्स को दिखा या छिपा सकें।
- विजेट को प्रदर्शित/दिखाने के लिए, पैक() . का उपयोग करें ज्यामिति प्रबंधक
- एप्लिकेशन से किसी भी विजेट को छिपाने के लिए, pack_forget() . का उपयोग करें विधि।
उदाहरण
आइए हम इस उदाहरण को समझने के लिए लेते हैं कि विजेट कैसे दिखाना/छिपाना है -
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame
win = Tk()
# Set the size of the tkinter window
win.geometry("700x350")
# Define the style for combobox widget
style = ttk.Style()
style.theme_use('xpnative')
# Define a function to show/hide widget
def show_widget():
label.pack()
def hide_widget():
label.pack_forget()
b1.configure(text="Show", command=show_widget)
# Add a label widget
label = ttk.Label(win, text="Eat, Sleep, Code and Repeat", font=('Aerial 11'))
label.pack(pady=30)
# Add a Button widget
b1 = ttk.Button(win, text="Hide", command=hide_widget)
b1.pack(pady=20)
win.mainloop() आउटपुट
उपरोक्त कोड को चलाने से एक विंडो खुलेगी जिसमें एप्लिकेशन से विजेट दिखाने/छिपाने के लिए एक बटन होगा।

अब, विंडो से लेबल टेक्स्ट को प्रदर्शित/छिपाने के लिए बटन पर क्लिक करें।
