Skip to content

CTkInputDialog

Tom Schimansky edited this page Nov 10, 2022 · 2 revisions

This is a simple dialog to input a string or number.

Example Code:

import customtkinter
import tkinter

customtkinter.set_appearance_mode("dark")

app = customtkinter.CTk()
app.geometry("400x300")


def button_click_event():
    dialog = customtkinter.CTkInputDialog(text="Type in a number:", title="Test")
    print("Number:", dialog.get_input())


button = customtkinter.CTkButton(app, text="Open Dialog", command=button_click_event)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)

app.mainloop()

This example code results in the following window and dialog:

Bildschirmfoto 2022-03-07 um 22 00 17

Arguments:

argument value
title string for the dialog title
text text for the dialog itself
fg_color window color, tuple: (light_color, dark_color) or single color
button_fg_color color of buttons, tuple: (light_color, dark_color) or single color
button_hover_color hover color of buttons, tuple: (light_color, dark_color) or single color
button_text_color text color of buttons, tuple: (light_color, dark_color) or single color
entry_fg_color color of entry, tuple: (light_color, dark_color) or single color
entry_border_color border color of entry, tuple: (light_color, dark_color) or single color
entry_text_color text color of entry, tuple: (light_color, dark_color) or single color

Methods:

input_value = dialog.get_input()  # opens the dialog

⚠️ Attention ⚠️

The Github Wiki is outdated, the new documentation can be found at:

https://customtkinter.tomschimansky.com

Clone this wiki locally