当前位置: 首页 > news >正文

pyqt 风格

#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 样式模块 定义全局样式表和动态样式生成 """ from typing import Dict class StyleManager: """样式管理器""" # 颜色常量 COLORS = { 'bg_dark': '#0F172A', 'bg_medium': '#1E293B', 'bg_light': '#334155', 'border': '#334155', 'border_focus': '#3B82F6', 'text_primary': '#F1F5F9', 'text_secondary': '#94A3B8', 'text_muted': '#64748B', 'accent_blue': '#3B82F6', 'accent_blue_hover': '#2563EB', 'accent_blue_pressed': '#1D4ED8', 'accent_green': '#10B981', 'accent_green_hover': '#059669', 'accent_green_pressed': '#047857', } @staticmethod def get_base_stylesheet(font_size: int = 13) -> str: """ 获取基础样式表 Args: font_size: 基础字号 Returns: 样式表字符串 """ c = StyleManager.COLORS return f""" /* 全局样式 */ QMainWindow {{ background-color: {c['bg_dark']}; }} QWidget {{ background-color: {c['bg_dark']}; color: {c['text_primary']}; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; font-size: {font_size}px; }} /* 分组框 */ QGroupBox {{ background-color: {c['bg_medium']}; border: 1px solid {c['border']}; border-radius: 8px; margin-top: 12px; padding: 15px; font-weight: bold; font-size: {int(font_size * 1.1)}px; }} QGroupBox::title {{ subcontrol-origin: margin; subcontrol-position: top left; padding: 0 10px; color: {c['accent_blue']}; background-color: {c['bg_medium']}; }} /* 输入框 */ QLineEdit {{ background-color: {c['bg_dark']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 8px 12px; color: {c['text_primary']}; selection-background-color: {c['accent_blue']}; }} QLineEdit:focus {{ border: 1px solid {c['accent_blue']}; }} QLineEdit:disabled {{ background-color: {c['bg_medium']}; color: {c['text_muted']}; }} /* 按钮 */ QPushButton {{ background-color: {c['accent_blue']}; border: none; border-radius: 6px; padding: 10px 20px; color: #FFFFFF; font-weight: bold; min-height: 20px; }} QPushButton:hover {{ background-color: {c['accent_blue_hover']}; }} QPushButton:pressed {{ background-color: {c['accent_blue_pressed']}; }} QPushButton:disabled {{ background-color: {c['bg_light']}; color: {c['text_muted']}; }} /* 次要按钮 */ QPushButton[secondary="true"] {{ background-color: {c['bg_light']}; }} QPushButton[secondary="true"]:hover {{ background-color: #475569; }} /* 下拉框 */ QComboBox {{ background-color: {c['bg_dark']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 8px 12px; color: {c['text_primary']}; min-width: 100px; }} QComboBox:hover {{ border: 1px solid {c['accent_blue']}; }} QComboBox::drop-down {{ border: none; width: 30px; }} QComboBox::down-arrow {{ image: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid {c['accent_blue']}; margin-right: 10px; }} QComboBox QAbstractItemView {{ background-color: {c['bg_medium']}; border: 1px solid {c['border']}; selection-background-color: {c['accent_blue']}; color: {c['text_primary']}; }} /* 数字输入框 */ QSpinBox, QDoubleSpinBox {{ background-color: {c['bg_dark']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 8px 12px; color: {c['text_primary']}; }} QSpinBox:focus, QDoubleSpinBox:focus {{ border: 1px solid {c['accent_blue']}; }} QSpinBox::up-button, QDoubleSpinBox::up-button {{ background-color: {c['bg_medium']}; border: none; width: 24px; subcontrol-origin: border; subcontrol-position: top right; height: 14px; }} QSpinBox::down-button, QDoubleSpinBox::down-button {{ background-color: {c['bg_medium']}; border: none; width: 24px; subcontrol-origin: border; subcontrol-position: bottom right; height: 14px; }} QSpinBox::up-arrow, QDoubleSpinBox::up-arrow {{ image: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 6px solid {c['accent_blue']}; }} QSpinBox::down-arrow, QDoubleSpinBox::down-arrow {{ image: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid {c['accent_blue']}; }} /* 滑块 */ QSlider::groove:horizontal {{ background: {c['bg_light']}; height: 8px; border-radius: 4px; }} QSlider::handle:horizontal {{ background: {c['accent_blue']}; width: 18px; height: 18px; margin: -5px 0; border-radius: 9px; }} QSlider::handle:horizontal:hover {{ background: {c['accent_blue_hover']}; }} QSlider::sub-page:horizontal {{ background: {c['accent_blue']}; border-radius: 4px; }} /* 进度条 */ QProgressBar {{ background-color: {c['bg_medium']}; border: none; border-radius: 4px; text-align: center; color: {c['text_primary']}; min-height: 8px; }} QProgressBar::chunk {{ background-color: {c['accent_blue']}; border-radius: 4px; }} /* 标签 */ QLabel {{ color: {c['text_primary']}; background-color: transparent; }} QLabel[heading="true"] {{ font-size: {int(font_size * 1.3)}px; font-weight: bold; color: {c['accent_blue']}; }} QLabel[muted="true"] {{ color: {c['text_secondary']}; }} /* 滚动区域 */ QScrollArea {{ background-color: transparent; border: none; }} QScrollArea > QWidget > QWidget {{ background-color: transparent; }} /* 分隔线 */ QFrame[frameShape="4"] {{ background-color: {c['border']}; }} """ @staticmethod def get_title_style(font_size: int = 22) -> str: """获取标题样式""" return f"font-size: {font_size}px; font-weight: bold; color: {StyleManager.COLORS['accent_blue']}; padding: 8px 0;" @staticmethod def get_preview_empty_style() -> str: """获取预览区空状态样式""" c = StyleManager.COLORS return f""" QLabel {{ background-color: {c['bg_dark']}; border: 2px dashed {c['border']}; border-radius: 8px; color: {c['text_muted']}; font-size: 13px; }} """ @staticmethod def get_preview_loaded_style() -> str: """获取预览区已加载样式""" c = StyleManager.COLORS return f""" QLabel {{ background-color: {c['bg_dark']}; border: 2px solid {c['accent_blue']}; border-radius: 8px; }} """ @staticmethod def get_start_button_style(font_size: int = 15) -> str: """获取开始按钮样式""" c = StyleManager.COLORS return f""" QPushButton {{ background-color: {c['accent_green']}; font-size: {font_size}px; }} QPushButton:hover {{ background-color: {c['accent_green_hover']}; }} QPushButton:pressed {{ background-color: {c['accent_green_pressed']}; }} QPushButton:disabled {{ background-color: {c['bg_light']}; }} """ @staticmethod def get_info_value_style() -> str: """获取信息值样式""" c = StyleManager.COLORS return f"background-color: {c['bg_dark']}; border-radius: 4px; padding: 6px;"
/* 智能识别系统 v2.0.1 - 暗色主题 - 全自适应UI */ /* 全局自适应基础 */ * { font-family: "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 13px; } QWidget { background-color: #1a1a2e; color: #eaeaea; } /* v2.0.1: 全局控件最小高度 - 确保文字不被遮挡 */ QLineEdit, QComboBox, QPushButton, QSpinBox, QDoubleSpinBox { min-height: 28px; } /* v2.0.1: 下拉框下拉按钮宽度 */ QComboBox::drop-down { width: 28px; } /* 主窗口 */ QMainWindow { background-color: #1a1a2e; } /* 导航栏 */ #navFrame { background-color: #16213e; border-right: 1px solid #0f3460; } #navTitle { color: #00d9ff; font-size: 16px; font-weight: bold; padding: 10px; } #navSeparator { background-color: #0f3460; max-height: 2px; } #navList { background-color: transparent; border: none; outline: none; } #navList::item { background-color: transparent; border-radius: 8px; padding: 12px 15px; margin: 3px 5px; } #navList::item:hover { background-color: #0f3460; } #navList::item:selected { background-color: #e94560; color: white; } #navInfo { color: #6c7a89; font-size: 11px; padding: 10px; } /* 页面容器 */ #pageFrame { background-color: #1a1a2e; } /* 分组框 */ QGroupBox { background-color: #16213e; border: 1px solid #0f3460; border-radius: 8px; margin-top: 12px; padding: 15px; font-weight: bold; } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; left: 15px; padding: 0 8px; color: #00d9ff; } /* 按钮 - v2.0.1 自适应 */ QPushButton { background-color: #0f3460; color: #eaeaea; border: none; border-radius: 6px; padding: 6px 16px; font-weight: bold; min-height: 28px; min-width: 60px; } QPushButton:hover { background-color: #e94560; } QPushButton:pressed { background-color: #c23a51; } QPushButton:disabled { background-color: #2d3748; color: #6c7a89; } /* 主要按钮 */ QPushButton[primary="true"] { background-color: #e94560; } QPushButton[primary="true"]:hover { background-color: #ff5a78; } /* 输入框 */ QLineEdit, QTextEdit, QPlainTextEdit { background-color: #0f0f1a; color: #eaeaea; border: 1px solid #0f3460; border-radius: 6px; padding: 8px 12px; selection-background-color: #e94560; } QLineEdit:focus, QTextEdit:focus, QPlainTextEdit:focus { border: 1px solid #00d9ff; } QLineEdit:disabled, QTextEdit:disabled { background-color: #16213e; color: #6c7a89; } /* 下拉框 - v2.0.1 自适应 */ QComboBox { background-color: #0f3460; color: #eaeaea; border: none; border-radius: 6px; padding: 6px 10px; min-height: 28px; min-width: 80px; } QComboBox:hover { background-color: #16213e; border: 1px solid #00d9ff; } QComboBox::drop-down { border: none; width: 28px; } QComboBox::down-arrow { image: none; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #00d9ff; margin-right: 10px; } QComboBox QAbstractItemView { background-color: #16213e; color: #eaeaea; border: 1px solid #0f3460; selection-background-color: #e94560; outline: none; } /* 滑块 */ QSlider::groove:horizontal { background: #0f3460; height: 8px; border-radius: 4px; } QSlider::handle:horizontal { background: #00d9ff; width: 18px; height: 18px; margin: -5px 0; border-radius: 9px; } QSlider::handle:horizontal:hover { background: #e94560; } /* 进度条 */ QProgressBar { background-color: #0f3460; border: none; border-radius: 4px; text-align: center; height: 20px; } QProgressBar::chunk { background-color: #00d9ff; border-radius: 4px; } /* 表格 */ QTableWidget, QTableView { background-color: #0f0f1a; alternate-background-color: #16213e; gridline-color: #0f3460; border: 1px solid #0f3460; border-radius: 6px; selection-background-color: #e94560; selection-color: white; } QTableWidget::item, QTableView::item { padding: 8px; } QTableWidget::item:selected, QTableView::item:selected { background-color: #e94560; } QHeaderView::section { background-color: #16213e; color: #00d9ff; padding: 10px; border: none; border-bottom: 2px solid #0f3460; font-weight: bold; } /* 列表 */ QListWidget { background-color: #0f0f1a; border: 1px solid #0f3460; border-radius: 6px; outline: none; } QListWidget::item { padding: 10px; border-radius: 4px; } QListWidget::item:hover { background-color: #16213e; } QListWidget::item:selected { background-color: #e94560; } /* 标签页 */ QTabWidget::pane { background-color: #16213e; border: 1px solid #0f3460; border-radius: 6px; } QTabBar::tab { background-color: #0f3460; color: #eaeaea; padding: 10px 25px; margin-right: 3px; border-top-left-radius: 6px; border-top-right-radius: 6px; } QTabBar::tab:hover { background-color: #16213e; } QTabBar::tab:selected { background-color: #e94560; color: white; } /* 滚动条 */ QScrollBar:vertical { background-color: #16213e; width: 12px; border-radius: 6px; } QScrollBar::handle:vertical { background-color: #0f3460; min-height: 30px; border-radius: 6px; } QScrollBar::handle:vertical:hover { background-color: #00d9ff; } QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { height: 0px; } QScrollBar:horizontal { background-color: #16213e; height: 12px; border-radius: 6px; } QScrollBar::handle:horizontal { background-color: #0f3460; min-width: 30px; border-radius: 6px; } QScrollBar::handle:horizontal:hover { background-color: #00d9ff; } QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal { width: 0px; } /* 复选框 */ QCheckBox { spacing: 8px; } QCheckBox::indicator { width: 18px; height: 18px; border-radius: 4px; border: 2px solid #0f3460; } QCheckBox::indicator:checked { background-color: #e94560; border-color: #e94560; } QCheckBox::indicator:hover { border-color: #00d9ff; } /* 单选框 */ QRadioButton { spacing: 8px; } QRadioButton::indicator { width: 18px; height: 18px; border-radius: 9px; border: 2px solid #0f3460; } QRadioButton::indicator:checked { background-color: #e94560; border-color: #e94560; } /* 旋转框 */ QSpinBox, QDoubleSpinBox { background-color: #0f0f1a; color: #eaeaea; border: 1px solid #0f3460; border-radius: 6px; padding: 5px 10px; } QSpinBox::up-button, QDoubleSpinBox::up-button, QSpinBox::down-button, QDoubleSpinBox::down-button { background-color: #0f3460; border: none; width: 20px; } QSpinBox::up-button:hover, QDoubleSpinBox::up-button:hover, QSpinBox::down-button:hover, QDoubleSpinBox::down-button:hover { background-color: #e94560; } /* 工具提示 */ QToolTip { background-color: #16213e; color: #eaeaea; border: 1px solid #00d9ff; padding: 5px 10px; border-radius: 4px; } /* 状态栏 */ QStatusBar { background-color: #16213e; border-top: 1px solid #0f3460; padding: 5px 15px; } /* 菜单 */ QMenu { background-color: #16213e; border: 1px solid #0f3460; border-radius: 6px; padding: 5px; } QMenu::item { padding: 8px 30px; border-radius: 4px; } QMenu::item:selected { background-color: #e94560; } QMenu::separator { height: 1px; background-color: #0f3460; margin: 5px 10px; } /* 消息框 */ QMessageBox { background-color: #16213e; } QMessageBox QLabel { color: #eaeaea; } /* 分割器 */ QSplitter::handle { background-color: #0f3460; } QSplitter::handle:horizontal { width: 3px; } QSplitter::handle:vertical { height: 3px; } /* 标签 */ QLabel { background-color: transparent; } QLabel[heading="true"] { color: #00d9ff; font-size: 16px; font-weight: bold; } /* 日志级别样式 */ QTextEdit#logWidget { font-family: "Consolas", "Courier New", monospace; font-size: 12px; }
http://www.jsqmd.com/news/860468/

相关文章:

  • 软件开发行业的机遇:程序员如何抓住行业发展的机会
  • Notepad2-mod终极指南:掌握这款高效开源文本编辑器的深度开发与扩展
  • 增加Passenger属性,用于储存旅客信息。
  • 剪映专业版教程:制作数据结构快速排序算法原理演示视频
  • 苏州沃虎电子(VOOHU)10G高速SMD网络变压器WHSM24002G产品介绍
  • 如何在脑电信号处理的星辰大海中,找到你的开源坐标?[特殊字符]
  • PPClaw一条命令跑起OpenClaw,值不值?
  • 2026郴州黄金回收实测:郴奢汇万宝店安全首选 - 小仙贝贝
  • 2026 国内全自动吹瓶机生产商 TOP5 排行榜 行业深度评测推荐 - 星城方舟
  • 别急着扔!斐讯K3刷机变砖自救指南:无需编程器,TTL线救砖与SPI双启动改造
  • 猫抓Cat-Catch技术演进三部曲:从浏览器嗅探到流媒体下载的完整实战指南
  • 如何在 IntelliJ IDEA 中配置多 JDK 版本快速切换?
  • 三角洲游戏护航平台:俱乐部接单平台游戏电竞护航陪玩源码系统小程序 - 壹软科技
  • 软件开发行业的标准化:如何建立统一的开发标准
  • 普宁蔡司眼镜哪里买正品|怎么判断一家门店是否是蔡司授权店 - 品牌观察
  • Codex插件
  • 深入TI毫米波雷达SDK:拆解IWR6843AOP Out of Box Demo的数据流与任务调度
  • 天津购宠避坑指南:5 家靠谱实体门店实测推荐 - 资讯纵览
  • 长期使用Taotoken Token Plan套餐的成本控制效果回顾
  • 普宁近视眼镜哪家配得好|怎么判断一家眼镜店配镜水平高不高 - 品牌观察
  • 普宁弱视矫正配镜哪家专业|孩子弱视去眼镜店还是医院 - 品牌观察
  • 想输出百分数需要多写一个
  • GPT-3.5和GPT-4写Prompt,差别到底在哪?
  • 2026年真实用户体验:改款一哥服务怎么样?从沟通到交付的一站式全流程感受 - 资讯纵览
  • 表格基础知识
  • 这份榜单够用!盘点2026年断层领先的的AI论文写作软件
  • 新手教程使用curl命令快速测试Taotoken平台大模型API连通性
  • 普宁眼镜店推荐哪家好|怎么快速筛掉不靠谱的眼镜店 - 品牌观察
  • 别让“职场压榨”,消耗掉你的人生!打工人该醒醒了
  • 2026年AI写作辅助网站测评:5款神器从选题到格式全流程护航