bms_hard.py 1.9 KB

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