In this video I’ll teach you how to use the input dialog box for customTkinter and Python.

The Input Dialog box allows you to create a popup box that accepts user input.

So a user can type an answer to a question, or anything else, in the box.

I’ll show you how to create them in CustomTkinter and how to customize the look of them as well.

Python Code: ctk_inputwindow.py
(Github Code)

from tkinter import *
import customtkinter

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 - CustomTkinter Input Window')
root.iconbitmap('images/codemy.ico')
root.geometry('400x200')

# Create Function
def input():
	dialog = customtkinter.CTkInputDialog(text="What is your Name?", title="Hello There!",
		fg_color="white",
		button_fg_color="red",
		button_hover_color="pink",
		button_text_color="black",
		entry_fg_color="green",
		entry_border_color="red",
		entry_text_color="black"


		)
	thing = dialog.get_input()
	if thing:
		my_label.configure(text=f"Hello {thing}")
	else:
		my_label.configure(text=f"You Forgot To Type Anything!")



# Create a Button
my_button = customtkinter.CTkButton(root, text="Click Me!", command=input)
my_button.pack(pady=40)

# Create a Label
my_label = customtkinter.CTkLabel(root, text='')
my_label.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

Add comment

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

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...