# oat-dark **Repository Path**: slmpt/oat-dark ## Basic Information - **Project Name**: oat-dark - **Description**: ttk-tkinter-主题美化,基于oatui组件库规范 - **Primary Language**: Python - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-24 - **Last Updated**: 2026-09-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # oat-dark 基于 **Oat UI** 组件库设计规范的 **ttk(Tkinter 主题控件)深色主题**。 ## 概述 oat-dark 是一个美观、现代的 ttk 深色主题,灵感来自 [Oat UI](https://oatui.netlify.app/) 组件库的设计令牌(design tokens)。所有界面元素均使用 PNG 精灵图绘制,并与 Oat UI 深色调色板保持同步。 ## 特性 - 🎨 **完整调色板** — 严格遵循 Oat UI 设计令牌(`--background`、`--foreground`、`--primary`、`--border` 等) - 🖼️ **精灵图渲染** — 所有控件均通过 PNG 精灵图绘制,支持 hover、focus、pressed、disabled、selected 等多状态 - 🧩 **控件支持全面** — 涵盖几乎所有 ttk 控件: - 按钮:普通按钮、强调色按钮(`Accent.TButton`)、工具栏按钮、切换按钮(`ToggleButton`) - 选择控件:复选框、单选按钮、开关(`Switch`) - 输入控件:输入框、数字调节框、组合框(普通和只读) - 菜单控件:菜单按钮、选项菜单 - 滚动控件:水平/垂直滚动条、滑块、进度条 - 容器控件:卡片(`Card`)、标签框架、笔记本(选项卡)、窗框面板 - 数据控件:树形视图、分隔线、尺寸调整柄 - 🌐 **跨平台** — 自动检测系统字体(优先使用 Segoe UI),适配 DPI 缩放 - 🐍 **开箱即用** — 提供 Tcl 主题文件和 Python 示例脚本 ## 使用方法 ### 在 Python/Tkinter 中使用 ```python import tkinter as tk from tkinter import ttk import os root = tk.Tk() # 创建样式对象 style = ttk.Style(root) # 导入 oat-dark 主题文件 root.tk.call("source", os.path.join("path/to", "oat-dark.tcl")) # 应用主题 style.theme_use("oat-dark") root.mainloop() ``` ### 在 Tcl/Tk 中使用 ```tcl source oat-dark.tcl ttk::style theme use oat-dark ``` ## 演示 运行 `example.py` 可查看包含所有控件的交互式演示: ```bash python example.py ``` ## 设计令牌 主题定义了以下颜色变量,应用程序可直接通过 `ttk::theme::oat-dark::colors` 数组访问: | Oat UI 令牌 | 值 | 用途 | |---|---|---| | `--background` | `#09090b` | 窗口/输入框背景 | | `--card` | `#18181b` | 凸起表面 | | `--secondary` | `#27272a` | 中性填充、选中行 | | `--border` | `#52525b` | 边框线、轮廓线 | | `--ring` | `#d4d4d8` | 焦点环 | | `--foreground` | `#fafafa` | 文本颜色 | | `--primary` | `#fafafa` | 强调色填充 | | `--primary-fg` | `#18181b` | 强调色上的文本 | | `--muted-fg` | `#a1a1aa` | 次要文本、图标 | | `--faint-fg` | `#71717a` | 禁用文本 | | `--danger` | `#f4807b` | 错误/危险状态 | | `--success` | `#6cc070` | 成功状态 | | `--warning` | `#f0a030` | 警告状态 | ## 项目结构 ``` oat-dark/ ├── oat-dark.tcl # 主主题文件(Tcl 样式定义) ├── example.py # Python 示例/演示脚本 ├── index.html # Oat UI 组件库文档(独立版) ├── LICENSE # MIT 许可证 ├── README.md # 本文件 └── oat-dark/ # PNG 精灵图目录 ├── rect-basic.png # 按钮基础状态 ├── rect-hover.png # 按钮悬停状态 ├── rect-accent.png # 强调色按钮 ├── border-basic.png # 输入框边框 ├── border-accent.png # 输入框焦点边框 ├── check-*.png # 复选框状态精灵图 ├── radio-*.png # 单选按钮状态精灵图 ├── switch-*.png # 开关状态精灵图 ├── tab-*.png # 选项卡状态精灵图 ├── thumb-*.png # 滑块手柄状态精灵图 ├── hor-*.png / vert-*.png # 滚动条/进度条精灵图 └── ... # 更多精灵图 ``` ## 许可证 [MIT](LICENSE) ## 作者 - slmpt([2955530366@qq.com](mailto:2955530366@qq.com)) ## 致谢 - 原始主题灵感来自 [rdbende/ttk-widget-factory](https://github.com/rdbende/ttk-widget-factory) - 设计语言基于 [Oat UI](https://oatui.netlify.app/) 组件库