statusbar.py 5.6 KB

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