Tkinter 的现代主题。 采用 Bootstrap 为灵感的时尚、响应式样式。 包括即用型小组件、30 多个主题以及用于构建美观、跨平台的应用程序的工具。
Tkinter 的现代主题。 采用 Bootstrap 为灵感的时尚、响应式样式。 包括即用型小组件、30 多个主题以及用于构建美观、跨平台的应用程序的工具。
Modern, themed tkinter — style any ttk widget with one keyword.
ttkbootstrap is a theming extension for tkinter. It generates flat,
Bootstrap-inspired light and dark themes on demand and adds a single bootstyle
keyword to every ttk widget, so you describe intent — "primary",
"success", "outline" — instead of hand-tuning colors or long ttk style
names.
bootstyle="success", bootstyle="info outline", bootstyle="round toggle". The same keyword means the same thing on every widget.Meter, DateEntry, Floodgauge, Tableview) and fully themed dialogs.Theme(...) API and a public toolkit for building custom widget styles.It's a styling layer for vanilla tkinter, not a new framework: the widgets stay tkinter's, and everything you already know about tkinter still applies.
python -m pip install ttkbootstrap
Then see it running — this opens a window with every widget and a theme picker:
ttkb demo
import ttkbootstrap as ttk
app = ttk.App(title="Hello")
ttk.Label(app, text="Hello from ttkbootstrap!").pack(padx=16, pady=(16, 8))
ttk.Button(app, text="Primary", bootstyle="primary").pack(padx=16, pady=4)
ttk.Button(app, text="Success", bootstyle="success").pack(padx=16, pady=4)
ttk.Button(app, text="Danger Outline", bootstyle="danger outline").pack(padx=16, pady=(4, 16))
app.mainloop()
A bootstyle value is a small grammar — a color, plus an optional modifier
and widget type — and the same keyword carries the same meaning across widgets:
ttk.Button(app, bootstyle="success")
ttk.Progressbar(app, bootstyle="success")
ttk.Entry(app, bootstyle="success")
Add a modifier or a type for variants: "info outline", "success round toggle",
"warning striped". The vocabulary is closed, so a typo fails loudly instead of
silently doing nothing. See the
bootstyle grammar
for the full reference.
Thirty curated light and dark themes, switchable at runtime:
app.theme_use("bootstrap-dark") # any theme by name
app.toggle_theme() # flip light <-> dark
Browse them in the themes gallery.
Design your own with the bundled editor — pick colors, preview them on live
widgets, and export a Theme(...) snippet for your app:
ttkb creator
Installing ttkbootstrap installs ttkb:
| Command | What it does |
|---|---|
ttkb version |
Print the installed version |
ttkb demo |
Open the widget demo |
ttkb convert-theme <file> |
Convert a 1.x theme file to the 2.x Theme(...) form |
ttkb creator |
Open ttkcreator, the theme designer |
See the command-line reference.
2.0 is a cleanup-and-consolidation release with some breaking changes — a canonical
bootstyle grammar, a new theme catalog, and App alongside Window. Most code
keeps working: legacy theme names and older spellings are accepted with a
deprecation warning. The
Migrating to 2.0
guide sorts every change into breaking / deprecated / notable / new.
Custom themes moved out of the package and into your own code. To bring one forward, convert the file 1.x saved:
ttkb convert-theme user.py -o brand.py
ttkbootstrap ships with the full Bootstrap Icons
set (2,000+ glyphs), rendered from a bundled font — theme-following, crisp at any
size, and no extra dependency. Add one with the icon= keyword:
ttk.Button(app, text="Settings", icon="gear-fill", bootstyle="primary")
Need other icon families — Font Awesome, Material, Lucide, and more? The tkinter-icons extension adds sixteen icon sets (61,000+ icons) alongside the built-in set.
Contributions are welcome — please check out our contributing guidelines.
This project is proudly developed with the support of the PyCharm IDE, generously provided by JetBrains.
© 2025 JetBrains s.r.o. JetBrains and the JetBrains logo are registered trademarks of JetBrains s.r.o.
暂无开放 Issues,或尚未同步最近议题。