home.py 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. import os
  4. from ui.own.palette_theme import set_my_palette
  5. from utils.qt import Qt, QWidget, QVBoxLayout, QHBoxLayout, QStackedWidget, QPixmap, QLabel, QPushButton, QSizePolicy, QLineEdit, QComboBox, QCoreApplication, QMetaObject, QIcon
  6. from utils.resource import resource_path
  7. class UiBmsHomePage(object):
  8. def setupUi(self, main):
  9. # main.resize(1366, 768)
  10. # main.setMinimumSize(1366, 768)
  11. # main.resize(1920, 1080)
  12. # main.setMinimumSize(1920, 1080)
  13. # main.resize(1280, 720)
  14. # main.setMinimumSize(1280, 720)
  15. main.resize(1440, 900)
  16. main.setMinimumSize(1440, 900)
  17. set_my_palette(main)
  18. self.central_widget = QWidget(main)
  19. self.main_layout = QVBoxLayout(self.central_widget)
  20. self.main_layout.setContentsMargins(0, 0, 0, 0)
  21. self.main_layout.setSpacing(0)
  22. # 主窗口上侧布局
  23. self.top_widget = QWidget(self.central_widget)
  24. # 主窗口上采用水平布局
  25. self.top_layout = QHBoxLayout(self.top_widget)
  26. self.top_layout.setContentsMargins(0, 0, 0, 0)
  27. self.top_layout.setSpacing(0)
  28. self.label = QLabel(self.top_widget)
  29. self.label.setText("")
  30. self.label.setTextFormat(Qt.RichText)
  31. self.label.setPixmap(QPixmap(resource_path(os.path.join("assets", "logo.png"))))
  32. self.label.setScaledContents(False)
  33. self.top_layout.addWidget(self.label)
  34. self.top_layout.addStretch()
  35. self.btn_start = QPushButton("启动")
  36. self.btn_start.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "start.png")))))
  37. self.top_layout.addWidget(self.btn_start)
  38. self.top_layout.addStretch()
  39. self.btn_stop = QPushButton("停止")
  40. self.btn_stop.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "stop.png")))))
  41. self.top_layout.addWidget(self.btn_stop)
  42. self.top_layout.addStretch()
  43. self.btn_cut = QPushButton("截图")
  44. self.btn_cut.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "cut.png")))))
  45. self.top_layout.addWidget(self.btn_cut)
  46. self.top_layout.addStretch()
  47. self.label_lb = QLabel("当前在线主控: ")
  48. self.top_layout.addWidget(self.label_lb)
  49. self.edt_online = QLineEdit()
  50. self.edt_online.setReadOnly(True)
  51. self.edt_online.setFixedWidth(500)
  52. self.top_layout.addWidget(self.edt_online)
  53. self.top_layout.addStretch()
  54. self.zkc = QLabel("主控选择:")
  55. self.top_layout.addWidget(self.zkc)
  56. self.cb_bcu = QComboBox()
  57. for i in range(15):
  58. self.cb_bcu.addItem("BCU" + str(i + 1))
  59. self.top_layout.addWidget(self.cb_bcu)
  60. self.top_layout.addStretch()
  61. self.ckc = QLabel("从控选择:")
  62. self.top_layout.addWidget(self.ckc)
  63. self.cb_bmu = QComboBox()
  64. for i in range(15):
  65. self.cb_bmu.addItem("CMU" + str(i + 1))
  66. self.top_layout.addWidget(self.cb_bmu)
  67. self.top_layout.addStretch()
  68. self.main_layout.addWidget(self.top_widget, 1)
  69. # 主窗口下侧布局
  70. self.under_widget = QWidget(self.central_widget)
  71. # 主窗口下采用水平布局
  72. self.under_layout = QHBoxLayout(self.under_widget)
  73. self.under_layout.setContentsMargins(0, 0, 0, 0)
  74. self.under_layout.setSpacing(0)
  75. # 主窗口下左侧布局
  76. self.under_left_widget = QWidget(self.under_widget)
  77. # 主窗口左侧采用垂直布局
  78. self.under_left_layout = QVBoxLayout(self.under_left_widget)
  79. self.under_left_layout.setContentsMargins(0, 0, 0, 0)
  80. self.under_left_layout.setSpacing(0)
  81. self.btn_main_control = QPushButton(self.under_left_widget)
  82. self.btn_main_control.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "home.png")))))
  83. self.btn_main_control.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  84. self.under_left_layout.addWidget(self.btn_main_control)
  85. self.btn_cell_inf = QPushButton(self.under_left_widget)
  86. self.btn_cell_inf.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "cell.png")))))
  87. self.btn_cell_inf.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  88. self.under_left_layout.addWidget(self.btn_cell_inf)
  89. self.btn_double_ccu = QPushButton(self.under_left_widget)
  90. self.btn_double_ccu.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "bcu.png")))))
  91. self.btn_double_ccu.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  92. self.under_left_layout.addWidget(self.btn_double_ccu)
  93. self.btn_protect_inf = QPushButton(self.under_left_widget)
  94. self.btn_protect_inf.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "protect.png")))))
  95. self.btn_protect_inf.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  96. self.under_left_layout.addWidget(self.btn_protect_inf)
  97. self.btn_hard_cali = QPushButton(self.under_left_widget)
  98. self.btn_hard_cali.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "hard.png")))))
  99. self.btn_hard_cali.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  100. self.under_left_layout.addWidget(self.btn_hard_cali)
  101. self.btn_balance_inf = QPushButton(self.under_left_widget)
  102. self.btn_balance_inf.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "balance.png")))))
  103. self.btn_balance_inf.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  104. self.under_left_layout.addWidget(self.btn_balance_inf)
  105. self.btn_data_inf = QPushButton(self.under_left_widget)
  106. self.btn_data_inf.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "data.png")))))
  107. self.btn_data_inf.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  108. self.under_left_layout.addWidget(self.btn_data_inf)
  109. self.btn_download = QPushButton(self.under_left_widget)
  110. self.btn_download.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "download.png")))))
  111. self.btn_download.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  112. self.under_left_layout.addWidget(self.btn_download)
  113. self.btn_set_inf = QPushButton(self.under_left_widget)
  114. self.btn_set_inf.setIcon(QIcon(QPixmap(resource_path(os.path.join("assets/icon", "set.png")))))
  115. self.btn_set_inf.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
  116. self.under_left_layout.addWidget(self.btn_set_inf)
  117. self.under_layout.addWidget(self.under_left_widget, 1)
  118. self.under_right_widget = QWidget(self.central_widget)
  119. self.under_right_layout = QVBoxLayout(self.under_right_widget)
  120. self.under_right_layout.setContentsMargins(0, 0, 0, 0)
  121. self.under_right_layout.setSpacing(0)
  122. self.bms_tab = QStackedWidget(self.under_right_widget)
  123. self.under_right_layout.addWidget(self.bms_tab)
  124. self.under_layout.addWidget(self.under_right_widget, 9)
  125. self.main_layout.addWidget(self.under_widget, 9)
  126. main.setCentralWidget(self.central_widget)
  127. self.retranslateUi(main)
  128. QMetaObject.connectSlotsByName(main)
  129. def retranslateUi(self, MainWindow):
  130. _translate = QCoreApplication.translate
  131. MainWindow.setWindowTitle(_translate("MainWindow", "EnergyMath"))
  132. # self.groupbox_bms_log.setTitle(_translate("MainWindow", "连接状态"))
  133. self.btn_main_control.setText("主控信息")
  134. self.btn_cell_inf.setText("单体信息")
  135. self.btn_double_ccu.setText("并簇信息")
  136. self.btn_protect_inf.setText("保护参数")
  137. self.btn_hard_cali.setText("硬件校准")
  138. self.btn_balance_inf.setText("均衡状态")
  139. self.btn_data_inf.setText("数据记录")
  140. self.btn_download.setText("下载调试")
  141. self.btn_set_inf.setText("设置")