CustomTkinter Documentation
repository·master·Indexed 12 days ago
https://github.com/tomschimansky/customtkinterA Python UI library built on top of Tkinter providing modern, customizable widgets with HighDPI scaling and system appearance adaptation (light/dark mode) for Windows, macOS, and Linux.
What's inside CustomTkinter
- CustomTkinter supports scrollable frames that can be configured with either vertical or horizontal orientation. These frames can contain any other CustomTkinter or standard Tkinter widgets.
Install CustomTkinter via pip
masterInstall the
customtkintermodule using pip. It is recommended to update frequently as the library is under active development.To install:
pip3 install customtkinterTo update an existing installation:
pip3 install customtkinter --upgradepip3 install customtkinterCreate a basic CustomTkinter application
masterTo create a window, use
customtkinter.CTk(). This is the CustomTkinter equivalent of the standard TkinterTkwindow. Widgets likeCTkButtonare used instead of standardtkinterwidgets to ensure modern styling and HighDPI scaling support.import customtkinter customtkinter.set_appearance_mode("System") customtkinter.set_default_color_theme("blue") app = customtkinter.CTk() # create CTk window app.geometry("400x240") def button_function(): print("button pressed") # Use CTkButton instead of tkinter Button button = customtkinter.CTkButton(master=app, text="CTkButton", command=button_function) button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER) app.mainloop()Run the CustomTkinter widget showroom
masterYou can quickly view all available widgets by running the built-in showroom function.
import customtkinter as ctk ctk.run_showroom()Add images to CTkButton
masterTo add an image to a
CTkButton, pass aPhotoImageobject to theimageargument.To remove text entirely, set
text="". Alternatively, use thecompoundoption to specify how the text and image should be positioned relative to each other.Configure appearance mode and color themes
masterCustomTkinter allows you to set the global appearance mode and the default color theme for all widgets.
Appearance Modes:
"System"(default): Adapts to the operating system's light/dark mode."light": Forces light mode."dark": Forces dark mode.
Color Themes:
"blue"(default)"dark-blue""green"
import customtkinter customtkinter.set_appearance_mode("System") # Modes: system, light, dark customtkinter.set_default_color_theme("blue") # Themes: blue, dark-blue, green