#!/usr/bin/env python # -*- encoding: utf-8 -*- from ui.hard import Hard from ui.own.frame_theme import MyFrame from utils.globalvar import SD from utils.qt import QMessageBox, Signal from functools import partial class Win_Hard(Hard, MyFrame): rtc_update_signal = Signal() def __init__(self, parent=None): super(Win_Hard, self).__init__(parent) self.setupUi(self) self.btn_rtc.clicked.connect(self._rtc_update) for i in range(64): self.hard_table.cellWidget(i, 2).editingFinished.connect(partial(self._set_diff, i)) def _rtc_update(self): self.rtc_update_signal.emit() def _set_diff(self, i): try: diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text()) self.hard_table.item(i, 4).setText(str(diff)) # 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()): # return # else: # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!") # self.hard_table.cellWidget(i, 1).setText("") # self.hard_table.cellWidget(i, 1).setFocus() # return except BaseException: # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!") # self.hard_table.cellWidget(i, 1).setText("") # self.hard_table.cellWidget(i, 1).setFocusPolicy(Qt.StrongFocus) return def can_connect_error(self): QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")