In this video I want to talk about Entry boxes for Custom Tkinter and Python.

Entry widgets are one of the most fundamental widgets in Tkinter, and with CustomTkinter you can customize them in lots of fun ways.

We’ll look at all the main widget attributes in this video, as well as how to grab data from and Entry box and Clear an Entry Box.

Python Code: ctk_entry.py
(Github Code)

from tkinter import *
import customtkinter

# Set the theme and color options
customtkinter.set_appearance_mode("dark")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue")  # Themes: blue (default), dark-blue, green

#root = Tk()
root = customtkinter.CTk()

root.title('Tkinter.com - Custom Tkinter Entry Fields')
root.iconbitmap('images/codemy.ico')
root.geometry('600x350')

def submit():
	my_label.configure(text=f'Hello {my_entry.get()}')
	my_entry.configure(state="disabled")

def clear():
	my_entry.configure(state="normal")
	my_entry.delete(0, END)

my_label = customtkinter.CTkLabel(root, text="", font=("Helvetica", 24))
my_label.pack(pady=40)

my_entry = customtkinter.CTkEntry(root, 
	placeholder_text="Enter Your Name",
	height=50,
	width=200,
	font=("Helvetica", 18),
	corner_radius=50,
	text_color="green",
	placeholder_text_color="darkblue",
	fg_color=("blue","lightblue"),  # outer, inner
	state="normal",
)
my_entry.pack(pady=20)

my_button = customtkinter.CTkButton(root, text="Submit", command=submit)
my_button.pack(pady=10)

clear_button = customtkinter.CTkButton(root, text="Clear", command=clear)
clear_button.pack(pady=10)




root.mainloop()

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

2 comments

Your email address will not be published. Required fields are marked *

  • I am getting this message when I go back to the terminal to enter python chat.py in the Create the app step. From this message, can you tell me what am I doing wrong?

    Traceback (most recent call last):
    File “C:\chatgpt\chat.py”, line 11, in
    root.iconbitmap(‘ai_lt.ico’)
    File “C:\chatgpt\virt\Lib\site-packages\customtkinter\windows\ctk_tk.py”, line 230, in iconbitmap
    super().wm_iconbitmap(bitmap, default)
    File “C:\Users\wwcol\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py”, line 2136, in wm_iconbitmap
    return self.tk.call(‘wm’, ‘iconbitmap’, self._w, bitmap)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    _tkinter.TclError: bitmap “ai_lt.ico” not defined
    (virt)

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...