05-py-window-styles打造Windows 11风格Python UI

支持多种库

  • Tkinter
  • Customtkinter
  • PyQt
  • PySide
  • WxPython
  • Pygame
  • Kivy
  • PySimpleGUI
  • DearPyGui

安装第三方库

1
pip install pywinstyles

使用 pywinstyles.apply_style() 函数将主题应用到该窗口

下面是测试代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import tkinter as tk
import pywinstyles

# 创建窗口
root = tk.Tk()

# 设置窗口大小
root.geometry("800x600") # 设置初始尺寸为800x600

# 应用Windows 11主题
pywinstyles.apply_style(root, "acrylic")

# 添加内容
label = tk.Label(root, text="Hello, World!", font=("Arial", 24), bg='#F0F0F0')
label.pack(pady=50) # 增加垂直间距使内容居中

# 运行窗口
root.mainloop()

效果如下

风格 效果
mica
acrylic
aero (GPU Heavy)
transparent (GPU Heavy)
optimised
win7
inverse
native
popup
dark
normal 不修改

05-py-window-styles打造Windows 11风格Python UI
https://pattianfang.github.io/2025/08/06/05-py-window-styles打造Windows 11风格Python UI/
作者
Pat Tian Fang
发布于
2025年8月6日
更新于
2025年8月6日
许可协议