Professional Documents
Culture Documents
Home
Jump to bottom
This is the official CustomTkinter documentation, where you can find detailed information on
all available widgets and some more information on how the themes and the appearance
mode works.
Feel free to ask questions in the Discussion tab when something is unclear, if you need help
with a project or if you want to show off your project made with CustomTkinter.
If you found a bug, please report it in the Issues tab and provide the complete error message
and a minimal example code that reproduces the error.
If you have ideas on improvements or requests for new widgets, you can also report these in
the Issues tab, but please inform yourself about previous requests to prevent duplicates.
Pages 29 by Tom Schimansky 2022
CustomTkinter
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
Themes
Jump to bottom
The colors can either be set to a single color name ( "red" ), a single hex color string
( "#FF0000" ) or a tuple color for a light mode color and dark mode color ( ("red",
"darkred") ). The current color will then be picked by the widget automatically according to
the current appearance mode. So by using the tuple color, the widgets can have different
colors in light and dark appearance mode. If you use a single color then this color will be used
for both light and dark appearance mode.
Example:
Themes
By default all colours are set by the color theme. Currently there a three themes available:
"blue" , "dark-blue" and "green" , where "blue" is the standard theme. All themes provide
tuple colors for a light and dark appearance mode.
You can set the theme at the beginning of your programming like the following:
import customtkinter
import customtkinter
customtkinter.set_default_color_theme("path/to/your/custom_theme.json")
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
AppearanceMode
Jump to bottom
Appearance Mode
The appearance mode decides, which color will be picked from tuple colors, if the color is
specified as a tuple color. You can set the appearance mode at any time with the following
command:
import customtkinter
If you set the appearance mode to "system" , the current mode is read from the operating
system. It will also adapt if the appearance mode of the operating system changes during the
runtime of the program. Note that on Linux it will be always in "light" mode if set to
"system" , because the mode can't get read from the operating system at the moment, this
will probably be implemented in the future.
Pages 29 by Tom Schimansky 2022
CustomTkinter
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
Packaging
Jump to bottom
And secondly, you have to include the customtkinter directory manually with the --add-data
option of pyinstaller. Because for some reason, pyinstaller doesn't automatically include
datafiles like .json from the library. You can find the install location of the customtkinter library
with the following command:
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
Scaling
Jump to bottom
customtkinter.deactivate_automatic_dpi_awareness()
Then the window will be blurry on Windows with a scaling value of more than 100%.
Custom scaling
In addition to the automatically detected scaling factor, you can also set your own scaling
factors for the application like the following:
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
��� Writing a lot of UI code without classes and in single .py file with global variables
like it's often done is a pain to read and very bad coding style!
The second recommendation is to never use the .place() geometry manager, but to use
.pack() for very small apps or .grid() in every other case. The problem with .place() is
that it seems simple at the beginning, when you just place a few widgets on a window. But
you block yourself from extending your app. If you want to insert a widget at the top, you
have to correct the positions of every other widgets below. With grid or pack all the
widgets move and align automatically with a given padding and min/max size. By using
place you will never get a consistent padding and a responsive window.
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
def button_callback(self):
print("button pressed")
if __name__ == "__main__":
app = App()
app.mainloop()
Small onefile example app with .grid()
Now we use the grid geometry manager to create a 2x2 grid system. The first row gets a
weight of 1 so it will expand. The second row has a default weight of 0 and will only be as big
as it needs to be to fit the widgets inside of it. Both columns get an equal weight of 1 so that
they expand equally and fill the window.
The textbook has a column span of 2 so it will fill the first row completely. By setting sticky to
nsew , we force the textbook to stick to all edges of the grid cells it is in. It will expand and
completely fill the first row. So set the x-padding to 20 on both sides and the y-padding to
(20, 0) so that there is no padding at the bottom. (It will come from the buttons and the entry
in the second row)
The entry and button get a padding of 20 on all sides and a sticky of ew , so that they will
expand horizontally and fill the whole grid cell they are in.
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("500x300")
self.title("small example app")
self.minsize(300, 200)
self.textbox = customtkinter.CTkTextbox(master=self)
self.textbox.grid(row=0, column=0, columnspan=2, padx=20, pady=(20, 0), sticky=
def button_callback(self):
self.textbox.insert("insert", self.combobox.get() + "\n")
if __name__ == "__main__":
app = App()
app.mainloop()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
Appearance mode
• Appearance mode
• CTkScrollableFrame
• Packaging (.exe or .app)
• CTkTabview
• HighDPI and Scaling
• CTkTextbox
• CTkScrollbar
Tutorial
• CTkButton
•
• CTkLabel
App structure and layout
•
• CTkEntry
Multiple frames
• CTkOptionMenu
• Create new widgets (Spinbox)
• CTkComboBox
• CTkSegmentedButton
CTk Widgets
• CTkSwitch
CTk (main window)
• CTkCheckBox
CTkToplevel (additional windows)
• CTkRadioButton
CTkFrame
• CTkSlider
• CTkProgressBar
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
Multiple frames
Jump to bottom
A frame should be created as a separate class, which also can be placed in a separate file or
module. You can then simply create an instance of the frame in your main app class and place
it on the window. Another big advantage is, that you can easily move the frame within the app
window, because you don't need to change the positions of all the widgets inside the frame.
In the following I created a frame which implements a group of radio buttons with a label as a
header. The class inherits from CTkFrame and will be extended by methods called get_value
and set_value to get and set the current selected radio button string:
class RadioButtonFrame(customtkinter.CTkFrame):
def __init__(self, *args, header_name="RadioButtonFrame", **kwargs):
super().__init__(*args, **kwargs)
self.header_name = header_name
self.radio_button_var = customtkinter.StringVar(value="")
def get_value(self):
""" returns selected value as a string, returns an empty string if nothing selected """
return self.radio_button_var.get()
This frame can now be placed on the app window by creating an instance of it, like you would
do for a standard CTkFrame :
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("500x300")
self.title("RadioButtonFrame test")
def print_value_frame_1(self):
print(f"Frame 1 value: {self.radio_button_frame_1.get_value()}")
if __name__ == "__main__":
app = App()
app.mainloop()
I also added a button a connected a command to print the current value of the radio button
frame 1 to the terminal. The window will look like the following:
And because the radio button frame is structured as a class, there can easily be created
multiple instances of it, like in the following example:
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
def __init__(self):
super().__init__()
self.geometry("500x300")
self.title("RadioButtonFrame test")
def print_value_frame_1(self):
print(f"Frame 1 value: {self.radio_button_frame_1.get_value()}")
def print_value_frame_2(self):
print(f"Frame 2 value: {self.radio_button_frame_2.get_value()}")
if __name__ == "__main__":
app = App()
app.mainloop()
Of course you could also add another attribute to the RadioButtonFrame class, so that you can
not only customize the header_name , but also the values of the radio buttons.
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
import customtkinter
class WidgetName(customtkinter.CTkFrame):
def __init__(self, *args,
width: int = 100,
height: int = 32,
**kwargs):
super().__init__(*args, width=width, height=height, **kwargs)
By doing this, you already have a widget that has a default size given by the default values of
the attributes width and height. And it also supports all attributes of a CTkFrame like fg_color
and corner_radius.
A simple implementation af a float based Spinbox could look like the following:
class FloatSpinbox(customtkinter.CTkFrame):
def __init__(self, *args,
width: int = 100,
height: int = 32,
step_size: Union[int, float] = 1,
command: Callable = None,
**kwargs):
super().__init__(*args, width=width, height=height, **kwargs)
self.step_size = step_size
self.command = command
def add_button_callback(self):
if self.command is not None:
self.command()
try:
value = float(self.entry.get()) + self.step_size
self.entry.delete(0, "end")
self.entry.insert(0, value)
except ValueError:
return
def subtract_button_callback(self):
if self.command is not None:
self.command()
try:
value = float(self.entry.get()) - self.step_size
self.entry.delete(0, "end")
self.entry.insert(0, value)
except ValueError:
return
Of course you could add a configure method or more attributes to configure the colors in the
init method.
But with the above implementation you can use the spin box like the following:
app = customtkinter.CTk()
spinbox_1.set(35)
print(spinbox_1.get())
app.mainloop()
Pages 29 by Tom Schimansky 2022
CustomTkinter
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTk (tkinter.Tk)
Jump to bottom
Example Code:
Structure of a CustomTkinter program without any class (not recommended):
app = customtkinter.CTk()
app.geometry("600x500")
app.title("CTk example")
app.mainloop()
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("600x500")
self.title("CTk example")
app = App()
app.mainloop()
Arguments:
argument value
Methods:
Methods:
• .configure(attribute=value, ...)
app.configure(fg_color=new_fg_color)
• .cget(attribute_name)
fg_color = app.cget("fg_color")
...
• .title(string)
• .geomtry(geometry_string)
• .minsize(width, height)
• .maxsize(width, height)
• .resizable(width, height)
• .after(milliseconds, command)
• .withdraw()
• .iconify()
• .deiconify()
• .state()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkToplevel
Jump to bottom
Example Code:
The following example shows how to create a toplevel window, which can be opened from the
main app widnow. Before the toplevel window gets created, it is checked if the window
already exists, to prevent opening the same window multiple times.
import customtkinter
class ToplevelWindow(customtkinter.CTkToplevel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.geometry("400x300")
class App(customtkinter.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.geometry("500x400")
self.toplevel_window = None
def open_toplevel(self):
if self.toplevel_window is None or not self.toplevel_window.winfo_exists():
self.toplevel_window = ToplevelWindow(self) # create window if its None or destroye
else:
self.toplevel_window.focus() # if window exists focus it
if __name__ == "__main__":
app = App()
app.mainloop()
argument value
Methods:
• .configure(attribute=value, ...)
toplevel.configure(fg_color=new_fg_color)
• .cget(attribute_name)
fg_color = toplevel.cget("fg_color")
...
• .title(string)
• .geomtry(geometry_string)
• .minsize(width, height)
• .resizable(width, height)
• .after(milliseconds, command)
• .withdraw()
• .iconify()
• .deiconify()
• .state()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkFrame
Jump to bottom
import customtkinter
class MyFrame(customtkinter.CTkFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.geometry("400x200")
self.grid_rowconfigure(0, weight=1) # configure grid system
self.grid_columnconfigure(0, weight=1)
self.my_frame = MyFrame(master=self)
self.my_frame.grid(row=0, column=0, padx=20, pady=20, sticky="nsew")
app = App()
app.mainloop()
argument value
width width in px
height height in px
Methods:
• .configure(attribute=value, ...)
• .cget(attribute_name)
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
• CTkScrollableFrame
• CTkTabview
• App structure and layout
• CTkTextbox
• Multiple frames
• CTkScrollbar
• Create new widgets (Spinbox)
• CTkButton
• CTkLabel
CTk Widgets
• CTkEntry
•
• CTkOptionMenu
CTk (main window)
•
• CTkComboBox
CTkToplevel (additional windows)
• CTkSegmentedButton
• CTkFrame
• CTkSwitch
• CTkCheckBox
• CTkRadioButton
• CTkSlider
• CTkProgressBar
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkScrollableFrame
Jump to bottom
import customtkinter
class MyFrame(customtkinter.CTkScrollableFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
app = App()
app.mainloop()
class MyFrame(customtkinter.CTkScrollableFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
app = App()
app.mainloop()
Arguments:
argument value
Methods:
• .configure(attribute=value, ...)
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkTabview
Jump to bottom
Example Code:
tabview = customtkinter.CTkTabview(app)
tabview.pack(padx=20, pady=20)
button_1 = customtkinter.Button(tab_1)
import customtkinter
class MyTabView(customtkinter.CTkTabview):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
# create tabs
self.add("tab 1")
self.add("tab 2")
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
app = App()
app.mainloop()
Arguments:
argument value
Methods:
• .configure(attribute=value, ...)
• .cget(attribute_name)
• .tab(name)
• .add(name)
• .delete(name)
• .set(name)
• .get()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkTextbox
Jump to bottom
Example Code:
textbox = customtkinter.CTkTextbox(app)
textbox.grid(row=0, column=0)
import customtkinter
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.grid_rowconfigure(0, weight=1) # configure grid system
self.grid_columnconfigure(0, weight=1)
app = App()
app.mainloop()
argument value
Methods:
• .configure(attribute=value, ...)
• .cget(attribute_name)
• .unbind(sequence, funcid=None)
Insert text at given index. Index for the tkinter.Text class is specified by 'line.character',
'end', 'insert' or other keywords described here: https://anzeljg.github.io/rin2/book2
/2405/docs/tkinter/text-index.html
• .get(index1, index2=None)
• .focus_set()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkScrollbar
Jump to bottom
Default theme:
app = customtkinter.CTk()
app.grid_rowconfigure(0, weight=1)
app.grid_columnconfigure(0, weight=1)
app.mainloop()
Arguments:
argument value
Methods:
scrollbar = CTkScrollbar(master)
scrollbar.configure(...)
value_1, value_2 = scrollbar.get()
scrollbar.set(value_1, value_2)
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkButton
Jump to bottom
Default theme:
def button_event():
print("button pressed")
Customized:
button = customtkinter.CTkButton(master=root_tk,
width=120,
height=32,
border_width=0,
corner_radius=8,
text="CTkButton",
command=button_event)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
Arguments:
argument value
spacing between text and image and button border in px, default is
border_spacing
2
button text font, tuple: (font_name, size), (set negative size value for
font
size in pixels)
set image orientation if image and text are given ("top", "left",
compound
"bottom", "right")
alignment of text an image in button ("n", "ne", "e", "se", "s", "sw",
anchor
"w", "nw", "center")
Methods:
• .configure(attribute=value, ...)
ctk_button.configure(border_width=new_borderwidth)
ctk_button.configure(image=new_image)
ctk_button.configure(text=new_text)
ctk_button.configure(command=callback_function)
...
• .cget(attribute_name)
state = ctk_button.cget("state")
text = ctk_button.cget("text")
...
• .invoke()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkLabel
Jump to bottom
Customized:
text_var = tkinter.StringVar(value="CTkLabel")
label = customtkinter.CTkLabel(master=root_tk,
textvariable=text_var,
width=120,
height=25,
fg_color=("white", "gray75"),
corner_radius=8)
label.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
Arguments:
argument value
text string
controls where the text is positioned if the widget has more space than
anchor
the text needs, default is "center"
control the postion of image relative to text, default is "center, other are:
compound
"top", "bottom", "left", "right"
specifies how multiple lines of text will be aligned with respect to each
justify other: "left" for flush left, "center" for centered (the default), or "right" for
right-justified
padx extra space added left and right of the text, default is 1
pady extra space added above and belowof the text, default is 1
Methods:
• .configure(attribute=value, ...)
ctk_label.configure(text=new_text)
...
• .cget(attribute_name)
text = ctk_label.cget("text")
...
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
Tutorial
• CTkScrollableFrame
App structure and layout
• CTkTabview
Multiple frames
• CTkTextbox
Create new widgets (Spinbox)
• CTkScrollbar
• CTkButton
CTk Widgets
• CTkLabel
• CTkEntry
• CTk (main window)
• CTkOptionMenu
• CTkToplevel (additional windows)
• CTkComboBox
• CTkFrame
• CTkSegmentedButton
• CTkSwitch
• CTkCheckBox
• CTkRadioButton
• CTkSlider
• CTkProgressBar
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkEntry
Jump to bottom
Customized:
entry = customtkinter.CTkEntry(master=root_tk,
placeholder_text="CTkEntry",
width=120,
height=25,
border_width=2,
corner_radius=10)
entry.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
Arguments
argument value
Methods:
• .configure(attribute=value, ...)
ctk_entry.configure(state=new_state)
ctk_entry.configure(textvariable=textvariable)
...
• .cget(attribute_name)
state = ctk_entry.cget("state")
...
• .delete(first_index, last_index=None)
Deletes characters from the widget, starting with the one at index first_index, up to but
not including the character at position last_index. If the second argument is omitted, only
the single character at position first is deleted.
• .insert(index, string)
• .get()
• .focus()
• .focus_force()
• .index(index)
• .icursor(index)
• .select_adjust(index)
• .select_from(index)
• .select_clear()
• .select_present()
• .select_range(start_index, end_index)
• .select_to(index)
• .xview(index)
• .xview_moveto(f)
• .xview_scroll(number, what)
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkOptionMenu
Jump to bottom
Without variable:
def optionmenu_callback(choice):
print("optionmenu dropdown clicked:", choice)
combobox = customtkinter.CTkOptionMenu(master=app,
values=["option 1", "option 2"],
command=optionmenu_callback)
combobox.pack(padx=20, pady=10)
combobox.set("option 2") # set initial value
With variable:
def optionmenu_callback(choice):
print("optionmenu dropdown clicked:", choice)
combobox = customtkinter.CTkOptionMenu(master=app,
values=["option 1", "option 2"],
command=optionmenu_callback,
variable=optionmenu_var)
combobox.pack(padx=20, pady=10)
Arguments:
argument value
"n", "s", "e", "w", "center", orientation of the text inside the
anchor
optionmenu, default is "w"
Methods:
• .configure(attribute=value, ...)
.configure(attribute=value, ...)
• .set(value)
Set optionemnu to specific string value. Value don't has to be part of the values list.
• .get()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkComboBox
Jump to bottom
Without variable:
def combobox_callback(choice):
print("combobox dropdown clicked:", choice)
combobox = customtkinter.CTkComboBox(master=app,
values=["option 1", "option 2"],
command=combobox_callback)
combobox.pack(padx=20, pady=10)
combobox.set("option 2") # set initial value
With variable:
def combobox_callback(choice):
print("combobox dropdown clicked:", choice)
combobox = customtkinter.CTkComboBox(master=app,
values=["option 1", "option 2"],
command=combobox_callback,
variable=combobox_var)
combobox.pack(padx=20, pady=10)
Arguments:
Arguments:
argument value
Methods:
Methods:
• .configure(attribute=value, ...)
• .set(value)
Set combobox to specific string value. Value don't has to be part of the values list.
• .get()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkSegmentedButton
Jump to bottom
Example Code:
Without variable:
def segmented_button_callback(value):
print("segmented button clicked:", value)
segemented_button = customtkinter.CTkSegmentedButton(master=app,
values=["Value 1", "Value 2", "Value 3"
command=segmented_button_callback)
segemented_button.pack(padx=20, pady=10)
segemented_button.set("Value 1") # set initial value
With variable:
segemented_button = customtkinter.CTkSegmentedButton(master=app,
values=["Value 1", "Value 2", "Value 3"
variable=segemented_button_var)
segemented_button.pack(padx=20, pady=10)
Arguments:
argument value
Methods:
• .configure(attribute=value, ...)
• .cget(attribute_name)
Set to specific value. If value is not in values list, no button will be selected.
• .get()
• .insert(index, value)
Insert new value at given index into segmented button. Value will be also inserted into the
values list.
• .move(new_index, value)
• .delete(value)
Remove value from segmented button and values list. If value is currently selected, no
button will be selected afterwards.
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkSwitch
Jump to bottom
Example Code:
Default theme:
switch_var = customtkinter.StringVar(value="on")
def switch_event():
print("switch toggled, current value:", switch_var.get())
Arguments:
argument value
text string
textvariable Tkinter StringVar to control the text
Methods:
• .configure(attribute=value, ...)
• .get()
• .select()
• .deselect()
Turn off switch (set value to 0), command will not be triggered.
• .toggle()
CustomTkinter Docs
• CTkScrollableFrame
General Information
• CTkTabview
• Home
• CTkTextbox
• Themes
• and Colors
CTkScrollbar
• Appearance
• CTkButton mode
• Packaging
• CTkLabel (.exe or .app)
• HighDPI
• CTkEntryand Scaling
• CTkOptionMenu
Tutorial
• CTkComboBox
• CTkSegmentedButton
• App structure and layout
• CTkSwitch
• Multiple frames
• CTkCheckBox
• Create new widgets (Spinbox)
• CTkRadioButton
• CTkSlider
CTk Widgets
• CTkProgressBar
• CTkInputDialog
CTk (main window)
• CTkToplevel (additional windows)
Utility
• CTkFrame
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkCheckBox
Jump to bottom
Default theme:
check_var = tkinter.StringVar("on")
def checkbox_event():
print("checkbox toggled, current value:", check_var.get())
Arguments:
argument value
text string
Methods:
• .configure(attribute=value, ...)
• .get()
• .select()
• .deselect()
Turn off checkbox (set value to 0), command will not be triggered.
• .toggle()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
Packaging (.exe or .app)
•
• Packaging (.exe or .app)
CTkScrollableFrame
•
• HighDPI and Scaling
CTkTabview
• CTkTextbox
Tutorial
• CTkScrollbar
• CTkButton
• App structure and layout
• CTkLabel
• Multiple frames
• CTkEntry
• Create new widgets (Spinbox)
• CTkOptionMenu
• CTkComboBox
CTk Widgets
• CTkSegmentedButton
CTk (main window)
• CTkSwitch
CTkToplevel (additional windows)
• CTkCheckBox
CTkFrame
• CTkRadioButton
• CTkSlider
• CTkProgressBar
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkRadioButton
Jump to bottom
Example Code:
Default theme:
radio_var = tkinter.IntVar(0)
def radiobutton_event():
print("radiobutton toggled, current value:", radio_var.get())
radiobutton_1.pack(padx=20, pady=10)
radiobutton_2.pack(padx=20, pady=10)
Arguments:
argument value
Methods:
• .configure(attribute=value, ...)
• .select()
Select radio button (set value to 1), command will not be triggered.
• .deselect()
Deselect radio button (set value to 0), command will not be triggered.
• .invoke()
Same action as if user would click the radio button, command will be triggered.
CustomTkinter Docs
General Information
• Home
• CTkScrollableFrame
Themes and Colors
• CTkTabview
Appearance mode
• CTkTextbox
Packaging (.exe or .app)
• CTkScrollbar
HighDPI and Scaling
• CTkButton
Tutorial
• CTkLabel
• CTkEntry
• App structure and layout
• CTkOptionMenu
• Multiple frames
• CTkComboBox
• Create new widgets (Spinbox)
• CTkSegmentedButton
• CTkSwitch
CTk Widgets
• CTkCheckBox
•
• CTkRadioButton
CTk (main window)
•
• CTkSlider
CTkToplevel (additional windows)
• CTkProgressBar
• CTkFrame
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkSlider
Jump to bottom
def slider_event(value):
print(value)
Arguments:
argument value
• .configure(attribute=value, ...)
• .set(value)
• .get()
value = ctk_slider.get()
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkProgressBar
Jump to bottom
Default theme:
progressbar = customtkinter.CTkProgressBar(master=root_tk)
progressbar.pack(padx=20, pady=10)
Arguments:
argument value
corner_radius corner_radius in px
Methods:
• .configure(attribute=value, ...)
• .set(value)
• .get()
value = ctk_progressbar.get()
• .start()
• .stop()
• .step()
Do single step manually otherwise done by .start() and .stop() automatic loop. Step size is
set by determinate_speed and indeterminate_speed attributes.
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkInputDialog
Jump to bottom
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())
app.mainloop()
argument value
Methods:
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkFont
Jump to bottom
This font can not be configured afterwards. The optional keywords can be normal/bold,
roman/italic, underline and overstrike.
The better way is to create a CTkFont object, which can be modified afterwards and can be
used for multiple widgets:
All widgets get a CTkFont object by default, so configuring the font of a widget is possible by
default.
A font object can also be applied to multiple widgets, and if it gets configured, the changes
get passed to all widgets using this font:
Arguments:
argument value
• .configure(attribute=value, ...)
• .cget(attribute_name)
• .measure(text)
Pass this method a string, and it will return the number of pixels of width that string will
take in the font.
• .metrics(option)
If you call this method with no arguments, it returns a dictionary of all the font metrics.
You can retrieve the value of just one metric by passing its name as an argument. Metrics
include:
ascent: Number of pixels of height between the baseline and the top of the highest
ascender.
descent: Number of pixels of height between the baseline and the bottom of the lowest
ascender.
linespace: Number of pixels of height total. This is the leading of type set solid in the
given font.
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
HighDPI and Scaling
• CTkScrollableFrame
• CTkTabview
Tutorial
• CTkTextbox
App structure and layout
• CTkScrollbar
Multiple frames
• CTkButton
Create new widgets (Spinbox)
• CTkLabel
• CTkEntry
CTk Widgets
• CTkOptionMenu
• CTkComboBox
• CTk (main window)
• CTkSegmentedButton
• CTkToplevel (additional windows)
• CTkSwitch
• CTkFrame
• CTkCheckBox
• CTkRadioButton
• CTkSlider
• CTkProgressBar
• CTkInputDialog
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git
TomSchimansky / CustomTkinter Public
CTkImage
Jump to bottom
Arguments:
argument value
If only light_image or only dark_image is given, the existing one will be used for both light
and dark mode.
Methods:
• .configure(attribute=value, ...)
• .cget(attribute_name)
CustomTkinter Docs
General Information
• Home
• Themes and Colors
• Appearance mode
• Packaging (.exe or .app)
• HighDPI and Scaling
Tutorial
CTk Widgets
Utility
• CTkFont
• CTkImage
https://github.com/TomSchimansky/CustomTkinter.wiki.git