aboutsummaryrefslogtreecommitdiff
path: root/test/placeholder.py
diff options
context:
space:
mode:
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()