bms_hard.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.hard import Hard
  4. from ui.own.frame_theme import MyFrame
  5. from ui.own.my_chart_view import MyChartView
  6. from utils.globalvar import SD
  7. from utils.qt import QMessageBox, QChart, QValueAxis, QHBoxLayout, QPainter, Qt, Signal, Slot, QLegendMarker
  8. from functools import partial
  9. class Win_Hard(Hard, MyFrame):
  10. rtc_update_signal = Signal()
  11. def __init__(self, parent=None):
  12. super(Win_Hard, self).__init__(parent)
  13. self.setupUi(self)
  14. self.btn_rtc.clicked.connect(self._rtc_update)
  15. for i in range(64):
  16. self.hard_table.cellWidget(i, 2).editingFinished.connect(partial(self._set_diff, i))
  17. def _rtc_update(self):
  18. self.rtc_update_signal.emit()
  19. def _set_diff(self, i):
  20. try:
  21. diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())
  22. self.hard_table.item(i, 4).setText(str(diff))
  23. # if int(self.hard_table.item(i, 2).text()) <= int(float(self.hard_table.cellWidget(i, 1).text())) <= int(self.hard_table.item(i, 3).text()):
  24. # return
  25. # else:
  26. # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
  27. # self.hard_table.cellWidget(i, 1).setText("")
  28. # self.hard_table.cellWidget(i, 1).setFocus()
  29. # return
  30. except BaseException:
  31. # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
  32. # self.hard_table.cellWidget(i, 1).setText("")
  33. # self.hard_table.cellWidget(i, 1).setFocusPolicy(Qt.StrongFocus)
  34. return
  35. def can_connect_error(self):
  36. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")