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

Tkinter में Entry में Placeholder कैसे Add करें?

Tkinter button, text, entry, dialogue और अन्य attributes जैसे widgets add करने की सुविधाएं प्रदान करता है जो एप्लिकेशन develop करने में मदद करते हैं। हालांकि, tkinter entry widget में placeholder include नहीं करता। Placeholders वो dummy text होते हैं जो entry widget में दिखाई देते हैं ताकि user को इसके बारे में inform किया जा सके।

इस लेख में, हम insert(default value, text) फंक्शन का उपयोग करके entry widget में placeholder add करेंगे जो 0 जैसे default value के साथ placeholder text लेता है।

उदाहरण

# Import tkinter library
from tkinter import *

# Create an instance of frame
win = Tk()

# Set geometry
win.geometry("700x400")

# Create a text Label
Label(win, text="Notepad", font=('Poppins bold', 25)).pack(pady=20)

text = StringVar()

# Create an entry widget
test = Entry(win, textvariable=text)
test.pack(fill='x', expand=True, padx=45, pady=45)
test.focus()

# Add a placeholder in the entry Widget
test.insert(0, "Enter any Text")

win.mainloop()

आउटपुट

उपरोक्त code चलाने से कुछ placeholder के साथ एक Entry Widget बनेगा।

Tkinter में Entry में Placeholder कैसे Add करें?

  1. Tkinter एंट्री विजेट के लिए डिफ़ॉल्ट टेक्स्ट कैसे सेट करें? Tkinter एंट्री विजेट के लिए डिफ़ॉल्ट टेक्स्ट कैसे सेट करें?

    Tkinter एंट्री विजेट का उपयोग यूज़र इनपुट से ली गई टेक्स्ट की एक सिंगल लाइन को प्रिंट और डिस्प्ले करने के लिए किया जाता है। इसका उपयोग लॉगिन फॉर्म, साइनअप फॉर्म और अन्य यूज़र इंटरैक्शन फॉर्म बनाने जैसे कई एप्लिकेशन में किया जाता है।हम insert() फंक्शन का उपयोग करके एंट्री विजेट के लिए डिफ़ॉल्ट टेक्स्

  1. Tkinter में Button Text Dynamically Resize कैसे करें? Tkinter में Button Text Dynamically Resize कैसे करें?

    मान लीजिए हमने Tkinter Frame में एक button और एक label बनाया है। Task है button text को dynamically resize करके इसके main window के अनुसार adjust करना। हम button widget का उपयोग करके button बना सकते हैं। हालांकि, button label dynamically बनाने के लिए कई अन्य functions उपयोग किए जाते हैं। इस उदाहरण म

  1. Tkinter Text Box की Contents Delete कैसे करें? Tkinter Text Box की Contents Delete कैसे करें?

    Tkinter कई functions और modules प्रदान करता है जिनके माध्यम से हम buttons, dialogue boxes, widgets, और बहुत कुछ के साथ fully featured applications बना सकते हैं। Text widget बनाने के लिए, हम tkinter entry widget function का उपयोग कर सकते हैं जो basically एक constructor है और यह tkinter के window या f