Convert Figma logo to code with AI

TomSchimansky logoCustomTkinter

A modern and customizable python UI-library based on Tkinter

12,125
1,108
12,125
519

Top Related Projects

An easy and fast way to create a Python GUI 🐍

Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, WxPython, and Remi into a simple, intuitive, and fun experience for both hobbyists and expert users.

18,253

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS

2,408

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.

12,734

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.

A gorgeous theme for Tkinter/ttk, based on the Sun Valley visual style ✨

Quick Overview

CustomTkinter is a modern and customizable Python UI-library based on Tkinter. It provides new, modern-looking widgets and features to create visually appealing and user-friendly graphical interfaces. CustomTkinter aims to simplify the process of creating attractive GUIs while maintaining compatibility with standard Tkinter.

Pros

  • Easy to use and integrate with existing Tkinter projects
  • Offers a modern and sleek appearance compared to standard Tkinter
  • Provides a wide range of customizable widgets and themes
  • Supports both light and dark mode

Cons

  • May have a steeper learning curve for those unfamiliar with Tkinter
  • Limited documentation compared to more established UI libraries
  • Potential compatibility issues with some Tkinter features or third-party plugins

Code Examples

  1. Creating a simple window with a button:
import customtkinter

customtkinter.set_appearance_mode("dark")
customtkinter.set_default_color_theme("blue")

app = customtkinter.CTk()
app.geometry("300x150")

def button_callback():
    print("Button clicked")

button = customtkinter.CTkButton(master=app, text="Click me", command=button_callback)
button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)

app.mainloop()
  1. Creating a slider with a label:
import customtkinter

app = customtkinter.CTk()
app.geometry("300x200")

def slider_event(value):
    label.configure(text=f"Slider value: {int(value)}")

slider = customtkinter.CTkSlider(master=app, from_=0, to=100, command=slider_event)
slider.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)

label = customtkinter.CTkLabel(master=app, text="Slider value: 0")
label.place(relx=0.5, rely=0.7, anchor=customtkinter.CENTER)

app.mainloop()
  1. Creating a tabview with multiple frames:
import customtkinter

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

tabview = customtkinter.CTkTabview(master=app)
tabview.pack(padx=20, pady=20)

tabview.add("Tab 1")
tabview.add("Tab 2")
tabview.add("Tab 3")

label1 = customtkinter.CTkLabel(master=tabview.tab("Tab 1"), text="Content of Tab 1")
label1.pack(padx=20, pady=20)

button = customtkinter.CTkButton(master=tabview.tab("Tab 2"), text="Button in Tab 2")
button.pack(padx=20, pady=20)

entry = customtkinter.CTkEntry(master=tabview.tab("Tab 3"), placeholder_text="Entry in Tab 3")
entry.pack(padx=20, pady=20)

app.mainloop()

Getting Started

To get started with CustomTkinter, follow these steps:

  1. Install CustomTkinter using pip:

    pip install customtkinter
    
  2. Import CustomTkinter in your Python script:

    import customtkinter
    
  3. Create a basic application:

    customtkinter.set_appearance_mode("dark")
    customtkinter.set_default_color_theme("blue")
    
    app = customtkinter.CTk()
    app.geometry("300x200")
    app.title("CustomTkinter Example")
    
    label = customtkinter.CTkLabel(master=app, text="Hello, CustomTkinter!")
    label.pack(padx=20, pady=20)
    
    app.mainloop()
    

This will create a simple dark-themed window with a label. You can now start adding more widgets and customizing your application as needed.

Competitor Comparisons

An easy and fast way to create a Python GUI 🐍

Pros of Tkinter-Designer

  • Allows designing GUI layouts visually using Figma
  • Generates Python code from Figma designs automatically
  • Supports custom themes and styling options

Cons of Tkinter-Designer

  • Limited to standard Tkinter widgets
  • Requires Figma for design process
  • Less flexibility for custom widget creation

Code Comparison

Tkinter-Designer (generated code):

import tkinter as tk

window = tk.Tk()
window.geometry("800x600")
window.configure(bg="#FFFFFF")

canvas = tk.Canvas(window, bg="#FFFFFF", height=600, width=800, bd=0, highlightthickness=0, relief="ridge")
canvas.place(x=0, y=0)

button_1 = tk.Button(window, text="Click me!", bg="#4CAF50", fg="white", font=("Arial", 14))
button_1.place(x=300, y=250, width=200, height=50)

CustomTkinter:

import customtkinter as ctk

ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("blue")

app = ctk.CTk()
app.geometry("800x600")

button = ctk.CTkButton(app, text="Click me!")
button.pack(padx=20, pady=20)

Python GUIs for Humans! PySimpleGUI is the top-rated Python application development environment. Launched in 2018 and actively developed, maintained, and supported in 2024. Transforms tkinter, Qt, WxPython, and Remi into a simple, intuitive, and fun experience for both hobbyists and expert users.

Pros of PySimpleGUI

  • Supports multiple GUI frameworks (Tkinter, Qt, WxPython, Remi)
  • Extensive documentation and examples
  • Large and active community

Cons of PySimpleGUI

  • Less modern and customizable appearance
  • Slightly more verbose syntax for complex layouts

Code Comparison

PySimpleGUI:

import PySimpleGUI as sg

layout = [[sg.Text("Hello World")], [sg.Button("OK")]]
window = sg.Window("Demo", layout)
event, values = window.read()

CustomTkinter:

import customtkinter as ctk

root = ctk.CTk()
label = ctk.CTkLabel(root, text="Hello World")
button = ctk.CTkButton(root, text="OK")
label.pack()
button.pack()
root.mainloop()

PySimpleGUI offers a more concise way to create layouts, while CustomTkinter follows a more traditional Tkinter-style approach. PySimpleGUI's event loop is simplified, whereas CustomTkinter uses the standard Tkinter mainloop.

Both libraries aim to simplify GUI creation in Python, but PySimpleGUI offers more flexibility in terms of backend choices, while CustomTkinter focuses on enhancing Tkinter with a modern look and feel.

18,253

Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS

Pros of Kivy

  • Cross-platform support for desktop and mobile applications
  • Rich set of UI elements and customizable widgets
  • Powerful graphics engine with OpenGL ES 2 support

Cons of Kivy

  • Steeper learning curve compared to CustomTkinter
  • Larger file size and resource consumption
  • Less native look and feel on some platforms

Code Comparison

CustomTkinter:

import customtkinter as ctk

app = ctk.CTk()
button = ctk.CTkButton(app, text="Click me!")
button.pack()
app.mainloop()

Kivy:

from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        return Button(text='Click me!')

MyApp().run()

Both CustomTkinter and Kivy offer modern GUI development capabilities for Python. CustomTkinter extends the traditional Tkinter library with a more contemporary look and feel, while Kivy provides a comprehensive framework for multi-touch applications. CustomTkinter is easier to learn for those familiar with Tkinter, whereas Kivy offers more advanced features for complex, cross-platform applications. The choice between the two depends on the specific requirements of your project and your familiarity with GUI development in Python.

2,408

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.

Pros of Phoenix

  • More comprehensive and mature framework with a wider range of widgets and features
  • Cross-platform compatibility, including native look and feel on different operating systems
  • Extensive documentation and larger community support

Cons of Phoenix

  • Steeper learning curve compared to CustomTkinter
  • Larger project size and potentially more complex setup
  • May be overkill for simpler GUI applications

Code Comparison

CustomTkinter:

import customtkinter as ctk

app = ctk.CTk()
button = ctk.CTkButton(app, text="Click me!")
button.pack()
app.mainloop()

Phoenix:

import wx

app = wx.App()
frame = wx.Frame(None, title="Example")
button = wx.Button(frame, label="Click me!")
frame.Show()
app.MainLoop()

Both frameworks offer ways to create GUI applications, but Phoenix provides a more comprehensive set of tools and widgets for complex applications, while CustomTkinter focuses on enhancing the standard Tkinter library with a modern look and feel. CustomTkinter may be easier for beginners or smaller projects, while Phoenix is better suited for larger, cross-platform applications requiring advanced features.

12,734

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.

Pros of Flet

  • Cross-platform support for web, desktop, and mobile applications
  • Simpler syntax and less boilerplate code compared to CustomTkinter
  • Built-in state management and reactive UI updates

Cons of Flet

  • Less mature and smaller community compared to CustomTkinter
  • Limited customization options for native-looking widgets
  • Steeper learning curve for developers familiar with traditional GUI frameworks

Code Comparison

CustomTkinter:

import customtkinter as ctk

root = ctk.CTk()
button = ctk.CTkButton(root, text="Click me!")
button.pack()
root.mainloop()

Flet:

import flet as ft

def main(page: ft.Page):
    page.add(ft.ElevatedButton(text="Click me!"))

ft.app(target=main)

Both frameworks aim to simplify GUI development in Python, but Flet offers a more modern, declarative approach with built-in responsiveness. CustomTkinter, on the other hand, provides a familiar Tkinter-like experience with enhanced aesthetics and customization options. The choice between the two depends on the specific project requirements and the developer's preferred coding style.

A gorgeous theme for Tkinter/ttk, based on the Sun Valley visual style ✨

Pros of Sun-Valley-ttk-theme

  • Provides a modern, sleek theme for tkinter applications without modifying the underlying tkinter structure
  • Offers both light and dark modes, enhancing user experience and accessibility
  • Easily integrable into existing tkinter projects with minimal code changes

Cons of Sun-Valley-ttk-theme

  • Limited to theming existing tkinter widgets, doesn't introduce new custom widgets
  • May require additional customization for complex UI designs
  • Less extensive documentation and examples compared to CustomTkinter

Code Comparison

Sun-Valley-ttk-theme:

import tkinter as tk
from tkinter import ttk
import sv_ttk

root = tk.Tk()
sv_ttk.set_theme("dark")
button = ttk.Button(root, text="Click me!")
button.pack()
root.mainloop()

CustomTkinter:

import customtkinter as ctk

ctk.set_appearance_mode("dark")
root = ctk.CTk()
button = ctk.CTkButton(root, text="Click me!")
button.pack()
root.mainloop()

Both libraries aim to enhance the visual appeal of tkinter applications, but they take different approaches. Sun-Valley-ttk-theme focuses on theming existing tkinter widgets, while CustomTkinter provides a set of custom widgets with modern designs and additional functionality. The choice between the two depends on the specific requirements of your project and the level of customization needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

PyPI PyPI - Downloads Downloads last 6 month PyPI - License LOC


Paypal donation button

Massive Thanks to all the People who Donated to help this Project 😇

Official website: https://customtkinter.tomschimansky.com

CustomTkinter is a python UI-library based on Tkinter, which provides new, modern and fully customizable widgets. They are created and used like normal Tkinter widgets and can also be used in combination with normal Tkinter elements. The widgets and the window colors either adapt to the system appearance or the manually set mode ('light', 'dark'), and all CustomTkinter widgets and windows support HighDPI scaling (Windows, macOS). With CustomTkinter you'll get a consistent and modern look across all desktop platforms (Windows, macOS, Linux).

| complex_example.py on Windows 11 with dark mode and 'blue' theme

| complex_example.py on macOS in light mode and standard 'blue' theme

Installation

Install the module with pip:

pip3 install customtkinter

Update existing installation: pip3 install customtkinter --upgrade
(update as often as possible because this library is under active development)

Documentation

The official documentation can be found here:

➡️ https://customtkinter.tomschimansky.com/documentation.

Example Program

To test customtkinter you can try this simple example with only a single button:

import customtkinter

customtkinter.set_appearance_mode("System")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue")  # Themes: blue (default), dark-blue, green

app = customtkinter.CTk()  # create CTk window like you do with the Tk 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()

which results in the following window on macOS:

In the examples folder, you can find more example programs and in the Documentation you can find further information on the appearance mode, scaling, themes and all widgets.

More Examples and Showcase

Appearance mode change and scaling change

CustomTkinter can adapt to the Windows 10/11 light or dark mode:

https://user-images.githubusercontent.com/66446067/204672968-6584f360-4c52-434f-9c16-25761341368b.mp4

| complex_example.py on Windows 11 with system appearance mode change and standard 'blue' theme

On macOS you either need python3.10 or higher or the anaconda python version to get a dark window header (Tcl/Tk >= 8.6.9 required):

https://user-images.githubusercontent.com/66446067/204673854-b6cbcfda-d9a1-4425-92a3-5b57d7f2fd6b.mp4

| complex_example.py on macOS with system appearance mode change, user-scaling change and standard 'blue' theme

Button with images

It's possible to put an image on a CTkButton. You just have to pass a PhotoImage object to the CTkButton with the image argument. If you want no text at all you have to set text="" or you specify how to position the text and image at once with the compound option:

| image_example.py on Windows 11

Scrollable Frames

Scrollable frames are possible in vertical or horizontal orientation and can be combined with any other widgets. | scrollable_frame_example.py on Windows 11

Integration of TkinterMapView widget

In the following example I used a TkinterMapView which integrates well with a CustomTkinter program. It's a tile based map widget which displays OpenStreetMap or other tile based maps:

https://user-images.githubusercontent.com/66446067/204675835-1584a8da-5acc-4993-b4a9-e70f06fa14b0.mp4

| examples/map_with_customtkinter.py from TkinterMapView repository on Windows 11

You can find the TkinterMapView library and example program here: https://github.com/TomSchimansky/TkinterMapView