customtkinter

customtkinter

Definitive guidelines for writing clean, maintainable, and performant customtkinter applications. This rule file enforces best practices for code structure, theming, component architecture, and common pitfalls.

cursor **/*.py

Der Skill

# customtkinter Best Practices

This document outlines the definitive best practices for developing applications with `customtkinter`. Adhering to these guidelines ensures your UI code is consistent, maintainable, performant, and leverages the full power of the library.

## 1. Code Organization: Class-Based Applications

Always structure your `customtkinter` applications using a class that inherits from `customtkinter.CTk`. This encapsulates UI logic, promotes modularity, and simplifies state management.

❌ BAD: Procedural spaghetti code
```python
import customtkinter as ctk

# Theme setup (often forgotten or inconsistent)
ctk.set_appearance_mode("System")
ctk.set_default_color_theme("blue")

app = ctk.CTk()
app.geometry("400x240")
app.title("My App")

def on_button_click():
    print("Button clicked!")
    # Logic mixed directly here

label = ctk.CTkLabel(app, text="Hello!")
label.pack(pady=10)

button = ctk.CTkButton(app, text="Click Me", command=on_button_click)
button.pack(pady=10)

app.mainloop()
```

✅

So wird es eingerichtet

1. Open the tool and start a new conversation, project or template.
2. Paste the text below wherever the tool keeps standing instructions
   — usually called system prompt, instructions, or persona.
3. Save it so it applies to every run rather than a single message.

Hat es bei Ihnen geklappt?

Woher es stammt

sanjeed5 CC0-1.0 Das Original