palette_theme.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @文件 :palette_theme.py
  5. @时间 :2022/01/15 19:42:22
  6. @作者 :None
  7. @版本 :1.0
  8. @说明 :主题
  9. '''
  10. import os
  11. from utils.globalvar import SD
  12. from utils.resource import resource_path
  13. from utils.qt import QPalette, QFont, QBrush, QPixmap, QColor, QIcon
  14. THEME = 0
  15. def set_my_palette(self):
  16. icon = QIcon()
  17. icon.addPixmap(QPixmap(resource_path(os.path.join("assets", "ic_launch.png"))), QIcon.Normal, QIcon.Off)
  18. self.setWindowIcon(icon)
  19. self.setAutoFillBackground(True)
  20. palette = QPalette()
  21. if THEME:
  22. # 背景图片
  23. palette.setBrush(QPalette.Window, QBrush(QPixmap(resource_path(os.path.join("assets", "background.jpeg")))))
  24. # 背景字体
  25. palette.setColor(QPalette.WindowText, QColor(255, 255, 255))
  26. palette.setColor(QPalette.ButtonText, QColor(255, 255, 255))
  27. palette.setColor(QPalette.Button, QColor("#1A1A1A"))
  28. palette.setColor(QPalette.Base, QColor("#1A1A1A"))
  29. palette.setColor(QPalette.Text, QColor(255, 255, 255))
  30. palette.setColor(QPalette.ToolTipBase, QColor(255, 255, 255))
  31. self.setPalette(palette)
  32. # 定义字体样式
  33. font = QFont('Microsoft YaHei')
  34. if SD.HIGH_DPI == 1:
  35. font.setPixelSize(17)
  36. self.setFont(font)
  37. def set_sure_background(self):
  38. palette = self.palette()
  39. palette.setColor(QPalette.Button, QColor("#99CC99"))
  40. self.setPalette(palette)
  41. self.setAutoFillBackground(True)
  42. self.setFlat(True)
  43. def set_edt_bg(self, color):
  44. palette = self.palette()
  45. palette.setColor(QPalette.Base, color)
  46. self.setPalette(palette)
  47. self.setAutoFillBackground(True)
  48. def set_edt_bg_white(self):
  49. palette = self.palette()
  50. palette.setColor(QPalette.Base, QColor("#FFFFFF"))
  51. self.setPalette(palette)
  52. self.setAutoFillBackground(True)
  53. def set_tab_bg(self):
  54. palette = QPalette()
  55. palette.setColor(QPalette.Active, QPalette.Button, QColor(0, 0, 255))
  56. self.setPalette(palette)
  57. self.setAutoFillBackground(True)
  58. def set_table_header_bg(self):
  59. palette = QPalette()
  60. palette.setColor(QPalette.Button, QColor("#FFA500"))
  61. self.setPalette(palette)
  62. self.setAutoFillBackground(True)
  63. def set_table_line_bg(self):
  64. palette = QPalette()
  65. palette.setColor(QPalette.Active, QPalette.ColorRole, QColor("#FFA500"))
  66. self.setPalette(palette)
  67. self.setAutoFillBackground(True)