statusbar.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @文件 :statusbar.py
  5. @时间 :2022/01/22 09:55:34
  6. @作者 :None
  7. @版本 :1.0
  8. @说明 :状态栏页面
  9. '''
  10. from utils.qt import QStatusBar, QLabel, QFrame, QProgressBar, QMetaObject, QCoreApplication, QRadioButton, QButtonGroup, Qt
  11. from utils.globalvar import SD
  12. class UiStatusBar(object):
  13. def setupUi(self, bms_status):
  14. self.statusbar = QStatusBar()
  15. # bms软件版本号
  16. self.lb_bms_version = QLabel()
  17. self.lb_bms_version.setFrameStyle(QFrame.Panel | QFrame.Raised)
  18. self.lb_bms_version.setLineWidth(3)
  19. self.lb_bms_version.setMidLineWidth(3)
  20. #本地时间
  21. self.lb_local_time = QLabel()
  22. self.lb_local_time.setFrameStyle(QFrame.Panel | QFrame.Raised)
  23. self.lb_local_time.setLineWidth(3)
  24. self.lb_local_time.setMidLineWidth(3)
  25. # bms连接状态
  26. self.label_bms_connect = QLabel()
  27. self.label_bms_connect.setFrameStyle(QFrame.Panel | QFrame.Raised)
  28. self.label_bms_connect.setLineWidth(3)
  29. self.label_bms_connect.setMidLineWidth(3)
  30. # BMS:SN
  31. self.lb_bms_sn = QLabel()
  32. self.lb_bms_sn.setFrameStyle(QFrame.Panel | QFrame.Raised)
  33. self.lb_bms_sn.setLineWidth(3)
  34. self.lb_bms_sn.setMidLineWidth(3)
  35. self.lb_strech = QLabel(" ")
  36. self.bms_upgrade_status = QProgressBar()
  37. self.bms_upgrade_status.setProperty("value", 0)
  38. self.bms_upgrade_status.setVisible(0)
  39. # self.led_status_normal = Led(self.statusbar)
  40. # self.lb_bms_normal = QLabel()
  41. # self.lb_bms_normal.setFrameStyle(QFrame.Panel | QFrame.Raised)
  42. # self.lb_bms_normal.setLineWidth(3)
  43. # self.lb_bms_normal.setMidLineWidth(3)
  44. self.qbg_status = QButtonGroup()
  45. self.qrb_status_normal = QRadioButton()
  46. self.qrb_status_normal.setAttribute(Qt.WA_TransparentForMouseEvents, True)
  47. self.qrb_status_normal.setFocusPolicy(Qt.NoFocus)
  48. self.qrb_status_warnest = QRadioButton()
  49. self.qrb_status_warnest.setAttribute(Qt.WA_TransparentForMouseEvents, True)
  50. self.qrb_status_warnest.setFocusPolicy(Qt.NoFocus)
  51. self.qrb_status_warner = QRadioButton()
  52. self.qrb_status_warner.setAttribute(Qt.WA_TransparentForMouseEvents, True)
  53. self.qrb_status_warner.setFocusPolicy(Qt.NoFocus)
  54. self.qrb_status_warn = QRadioButton()
  55. self.qrb_status_warn.setAttribute(Qt.WA_TransparentForMouseEvents, True)
  56. self.qrb_status_warn.setFocusPolicy(Qt.NoFocus)
  57. self.qbg_status.addButton(self.qrb_status_normal, 0)
  58. self.qbg_status.addButton(self.qrb_status_warnest, 1)
  59. self.qbg_status.addButton(self.qrb_status_warner, 2)
  60. self.qbg_status.addButton(self.qrb_status_warn, 3)
  61. # self.qrb_status_normal.setText("正常")
  62. # self.lb_bms_normal = QLabel()
  63. # self.lb_bms_normal.setFrameStyle(QFrame.Panel | QFrame.Raised)
  64. # self.lb_bms_normal.setLineWidth(3)
  65. # self.lb_bms_normal.setMidLineWidth(3)
  66. # self.led_status_normal = Led(self.statusbar)
  67. # self.lb_bms_normal = QLabel()
  68. # self.lb_bms_normal.setFrameStyle(QFrame.Panel | QFrame.Raised)
  69. # self.lb_bms_normal.setLineWidth(3)
  70. # self.lb_bms_normal.setMidLineWidth(3)
  71. # self.led_status_normal = Led(self.statusbar)
  72. # self.lb_bms_normal = QLabel()
  73. # self.lb_bms_normal.setFrameStyle(QFrame.Panel | QFrame.Raised)
  74. # self.lb_bms_normal.setLineWidth(3)
  75. # self.lb_bms_normal.setMidLineWidth(3)
  76. # 往状态栏中添加组件(stretch应该是拉伸组件宽度)
  77. self.statusbar.addWidget(self.lb_bms_version, stretch=0)
  78. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  79. self.statusbar.addWidget(self.lb_local_time, stretch=0)
  80. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  81. self.statusbar.addWidget(self.label_bms_connect, stretch=0)
  82. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  83. self.statusbar.addWidget(self.lb_bms_sn, stretch=0)
  84. # self.statusbar.addWidget(self.label_bms_received, stretch=0)
  85. self.statusbar.addPermanentWidget(self.qrb_status_normal, stretch=0)
  86. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  87. self.statusbar.addPermanentWidget(self.qrb_status_warnest, stretch=0)
  88. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  89. self.statusbar.addPermanentWidget(self.qrb_status_warner, stretch=0)
  90. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  91. self.statusbar.addPermanentWidget(self.qrb_status_warn, stretch=0)
  92. # self.statusbar.addWidget(self.lb_strech, stretch=0)
  93. # self.statusbar.addPermanentWidget(self.lb_bms_normal, stretch=0)
  94. self.statusbar.addPermanentWidget(self.bms_upgrade_status, stretch=0)
  95. self.statusbar.setSizeGripEnabled(False)
  96. self.retranslateUi(bms_status)
  97. QMetaObject.connectSlotsByName(bms_status)
  98. def retranslateUi(self, bms_status):
  99. _translate = QCoreApplication.translate
  100. self.label_bms_connect.setText(_translate("bms_status", "通讯未连接" if SD.SYSTEM_LANGUAGE == 0 else "Not Connected"))
  101. self.lb_bms_sn.setText(_translate("bms_status", "BATSN:EM0123456"))
  102. self.qrb_status_normal.setText(_translate("bms_status", "正常" if SD.SYSTEM_LANGUAGE == 0 else "Normal"))
  103. self.qrb_status_warnest.setText(_translate("bms_status", "三级告警" if SD.SYSTEM_LANGUAGE == 0 else "Warnest"))
  104. self.qrb_status_warner.setText(_translate("bms_status", "二级告警" if SD.SYSTEM_LANGUAGE == 0 else "Warner"))
  105. self.qrb_status_warn.setText(_translate("bms_status", "一级告警" if SD.SYSTEM_LANGUAGE == 0 else "Warn/Fault"))