|
|
"""
|
|
|
无人机决策系统 - 界面样式模块
|
|
|
作者:XXX
|
|
|
日期:2025-07-13
|
|
|
功能说明:
|
|
|
本模块定义Tkinter界面控件的统一样式,提升界面美观性和一致性。
|
|
|
"""
|
|
|
import tkinter as tk
|
|
|
from tkinter import ttk
|
|
|
|
|
|
def apply_style(root):
|
|
|
"""
|
|
|
应用统一的界面样式
|
|
|
:param root: 根窗口或Toplevel窗口
|
|
|
"""
|
|
|
style = ttk.Style(root)
|
|
|
|
|
|
# 设置主题
|
|
|
style.theme_use('clam')
|
|
|
|
|
|
# 配置基本样式
|
|
|
style.configure('.', background='#ecf0f1', foreground='#2c3e50')
|
|
|
style.configure('TFrame', background='#ecf0f1')
|
|
|
style.configure('TLabel', background='#ecf0f1', foreground='#2c3e50')
|
|
|
style.configure('TButton', padding=6, relief='flat', background='#3498db')
|
|
|
style.configure('TEntry', padding=5, relief='flat')
|
|
|
style.configure('TText', background='white', foreground='black')
|
|
|
|
|
|
# 强调按钮样式
|
|
|
style.configure('Accent.TButton', background='#e74c3c', foreground='white')
|
|
|
|
|
|
# 树状视图样式
|
|
|
style.configure('Treeview',
|
|
|
background='white',
|
|
|
foreground='#2c3e50',
|
|
|
fieldbackground='white',
|
|
|
rowheight=25)
|
|
|
|
|
|
style.map('Treeview',
|
|
|
background=[('selected', '#3498db')],
|
|
|
foreground=[('selected', 'white')])
|
|
|
|
|
|
# 标签页样式
|
|
|
style.configure('TNotebook', background='#ecf0f1')
|
|
|
style.configure('TNotebook.Tab',
|
|
|
padding=[10, 5],
|
|
|
background='#bdc3c7',
|
|
|
foreground='#2c3e50')
|
|
|
style.map('TNotebook.Tab',
|
|
|
background=[('selected', '#3498db')],
|
|
|
foreground=[('selected', 'white')])
|
|
|
|
|
|
# 滚动条样式
|
|
|
style.configure('Vertical.TScrollbar',
|
|
|
gripcount=0,
|
|
|
background='#bdc3c7',
|
|
|
troughcolor='#ecf0f1',
|
|
|
arrowcolor='#2c3e50')
|
|
|
|
|
|
style.configure('Horizontal.TScrollbar',
|
|
|
gripcount=0,
|
|
|
background='#bdc3c7',
|
|
|
troughcolor='#ecf0f1',
|
|
|
arrowcolor='#2c3e50')
|
|
|
|
|
|
# 设置窗口背景色
|
|
|
root.configure(background='#ecf0f1') |