mcpField
C
customtkinter

customtkinter

github.com/kenvindevDevelopment044 installsUpdated 34w ago
Repository

About customtkinter

CustomTkinter is a tkinter-based library for building Python graphical interfaces. Its guidance covers themed windows, appearance settings, and common layout methods.

Key features

  1. 01Create main and secondary windows
  2. 02Set light or dark appearance
  3. 03Configure a default color theme
  4. 04Arrange widgets with pack, grid, or place

Use cases

  1. 01Build a Python graphical application
  2. 02Set an app’s light or dark appearance
  3. 03Create forms, tabs, or scrollable areas

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/kenvindev/customtkinter-skill --skill customtkinter

After installing, type/customtkinterin Claude Code to confirm it loaded.

Bundled filesexamples.mdreference.md

Details

From the project README

CustomTkinter

Quick Start

import customtkinter

app = customtkinter.CTk()
app.geometry("600x500")
app.title("My App")
# thêm widgets...
app.mainloop()

Cài đặt: pip install customtkinter

Quy tắc chung

  1. Dùng CTk() thay vì Tk() – Theme chỉ áp dụng khi dùng CTk. Không dùng tkinter.Tk().
  2. Một instance CTk duy nhất – Chỉ một cửa sổ chính, gọi .mainloop() một lần.
  3. Cửa sổ phụ – Dùng CTkToplevel(master). Không gọi mainloop cho toplevel.
  4. Layout – Dùng pack(), grid(), hoặc place() như tkinter chuẩn.

Cấu trúc app với class

class App(customtkinter.CTk):
    def __init__(self):
        super().__init__()
        self.geometry("600x500")
        self.title("My App")
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        # thêm widgets...

app = App()
app.mainloop()

Màu sắc

  • Single color: fg_color="red" hoặc fg_color="#FF0000"
  • Tuple (light, dark): fg_color=("#DB3E39", "#821D1A") – tự chọn theo appearance mode

Theme và Appearance

# Trước khi tạo CTk()
customtkinter.set_appearance_mode("system")  # "dark" | "light" | "system"
customtkinter.set_default_color_theme("blue")  # "blue" | "green" | "dark-blue" | "path/to.json"

Toplevel – tránh mở trùng cửa sổ

def open_toplevel(self):
    if self.toplevel_window is None or not self.toplevel_window.winfo_exists():
        self.toplevel_window = ToplevelWindow(self)
    else:
        self.toplevel_window.focus()

Tài liệu bổ sung

  • Chi tiết API widgets, windows, colors, packaging: reference.md
  • Mẫu code: app cơ bản, form, tabview, scrollable frame, dialog: examples.md

Comments

Markdown supported