Skip to content

tomlin7/hintedtext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hinted Text

Hinted text widget for tkinter.

This custom HintedText class inherits from tk.Text and adds a hint parameter in the constructor. The clear_hint method is bound to the <FocusIn> event and will clear the hint text if the widget has focus and the text is the same as the hint. The add_hint method is bound to the <FocusOut> event and will add the hint text back if the widget loses focus and the text is empty.

Installation

pip install hintedtext

Usage

import tkinter as tk
from hintedtext import HintedText, HintedEntry

root = tk.Tk()
text = HintedText(root, hint="Enter your text here")
text.pack()
entry = HintedEntry(root, hint="Enter your text here")
entry.pack()
root.mainloop()