aboutsummaryrefslogtreecommitdiff
path: root/test/placeholder.py
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:23:10 +0530
committerVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:23:10 +0530
commit8f0751170385989677392f806762a211f99412ef (patch)
treef09ad917798fa313edb77925a1ddbc6de8fb37ce /test/placeholder.py
First Commit
Diffstat (limited to 'test/placeholder.py')
-rw-r--r--test/placeholder.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/placeholder.py b/test/placeholder.py
new file mode 100644
index 0000000..7b425c0
--- /dev/null
+++ b/test/placeholder.py
@@ -0,0 +1,24 @@
+import tkinter as tk
+
+root = tk.Tk()
+
+placeholder = 'Your text here'
+
+def erase(event=None):
+ if e.get() == placeholder:
+ e.delete(0,'end')
+def add(event=None):
+ if e.get() == '':
+ e.insert(0,placeholder)
+
+e = tk.Entry(root)
+e.pack(padx=10,pady=10)
+
+dummy = tk.Entry(root) #dummy widget just to see other widget lose focus
+dummy.pack(padx=10,pady=10)
+
+add()
+e.bind('<FocusIn>',erase)
+e.bind('<FocusOut>',add)
+
+root.mainloop()