Tkinter Entry – Text Color
In Tkinter, you can set the color of text in an Entry widget with a required color value.
![Tkinter Entry - Text Color](https://pythonexamples.org/wp-content/uploads/2023/07/pe070417.png)
To set the text color of an Entry widget in Tkinter, pass required color value to the fg parameter to the Entry class constructor, as shown below.
tk.Entry(window, bg="lightgreen")
tk.Entry(window, bg="#FFFF00")
In this tutorial, you will learn how to set the Entry widget text color with a required color value, with examples.
Examples
1. Set Entry widget text color to blue
In this example, we create a basic Tk window with an Entry widget and set its text color with the “blue” value.
Python Program
import tkinter as tk
# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")
window.geometry("300x200")
label = tk.Label(window, text="Enter your input")
label.pack()
# Create an Entry widget with specific text color
entry = tk.Entry(window, fg="blue")
entry.pack()
# Run the application
window.mainloop()
Output
In Windows
In MacOS
![Tkinter Entry with text color of "blue"](https://pythonexamples.org/wp-content/uploads/2023/07/pe070417.png)
2. Set Entry widget text color to blue with HEX value of “#FF0000”
In this example, we create a basic Tk window with an Entry widget and set its text color with a RGB HEX value of “#FF1122”.
Python Program
import tkinter as tk
# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")
window.geometry("300x200")
label = tk.Label(window, text="Enter your input")
label.pack()
# Create an Entry widget with specific text color
entry = tk.Entry(window, fg="#FF1122")
entry.pack()
# Run the application
window.mainloop()
Output
In Windows
In MacOS
![Tkinter Entry with text color "#FF1122"](https://pythonexamples.org/wp-content/uploads/2023/07/pe070418.png)
Summary
In this Python Tkinter tutorial, we have seen how to set the text color of an Entry widget in Tkinter, with examples.