华荣三照明、合信、荣欣八组合馈电

This commit is contained in:
冯佳
2025-06-25 11:36:43 +08:00
parent 37d39f4578
commit 25b3cb7f2e
494 changed files with 114074 additions and 0 deletions

View File

@ -0,0 +1,155 @@
import sys
import os
from PyQt5.QtWidgets import QApplication, QDialog, QLineEdit, QLabel, QWidget, QPushButton, QMessageBox, QComboBox, QDialogButtonBox, QShortcut
from PyQt5 import uic
from PyQt5.QtGui import QKeySequence
from PyQt5.QtCore import Qt, QEvent, QObject, QTimer
from Shared_CODE.get_tip_prop import *
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
ui_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../Shared_UI'))
ui_file_path = os.path.join(ui_path, "DialogModifyText.ui")
def modify_string(string, index, new_char):
string_list = list(string)
string_list[index] = new_char
modified_string = ''.join(string_list)
return modified_string
def chr_adjust(old_chr, dif : int) :
new_chr = old_chr
if old_chr == '+':
new_chr = '-'
elif old_chr == '-':
new_chr = '+'
elif dif > 0:
new_chr = chr(ord(old_chr) + 1)
if new_chr > '9' :
new_chr = '0'
else :
new_chr = chr(ord(old_chr) - 1)
if new_chr < '0' :
new_chr = '9'
return new_chr
class DialogModifyText(QDialog):
def __init__(self, main_window, parent=None):
super(DialogModifyText, self).__init__(parent)
# Load UI file
uic.loadUi(ui_file_path, self)
self.Text = "2019-09-10 10:22:23"
self.select_bit = 0
self.main_window = main_window
self.setWindowTitle("参数修改")
self.setWindowFlag(Qt.FramelessWindowHint)
self.buttonBox.button(QDialogButtonBox.Ok).setText(' ')
self.buttonBox.button(QDialogButtonBox.Cancel).setText(' ')
self.buttonBox.clicked.connect(self.dialog_button_ok_clicked)
modify_text = self.Text
self.update_modify_info(modify_text, "缺省多字符修改")
#让定时器周期刷修改字符串, 防止出现焦点切换时选中消失的情况
self.timer = QTimer(self)
self.timer.timeout.connect(self.timeout_modify_string_refresh)
self.timer.start(100)
#定义4个快捷键, Key_Enter, Key_Escape经常被各类程序模块使用, 用Key_End, 与Key_Home来代替
QShortcut(QKeySequence(Qt.Key_Up), self, activated=self.key_increase_parameter)
QShortcut(QKeySequence(Qt.Key_Down), self, activated=self.key_decrease_parameter)
# QShortcut(QKeySequence(Qt.Key_PageDown), self, activated=self.key_enter_process)
# QShortcut(QKeySequence(Qt.Key_PageUp), self, activated=self.key_escape_process)
QShortcut(QKeySequence(Qt.Key_End), self, activated=self.key_enter_process)
QShortcut(QKeySequence(Qt.Key_Home), self, activated=self.key_escape_process)
home_button = self.findChild(QPushButton, "KEY_HOME")
if home_button:
home_button.clicked.connect(self.key_escape_process)
end_button = self.findChild(QPushButton, "KEY_END")
if end_button:
end_button.clicked.connect(self.key_enter_process)
up_button = self.findChild(QPushButton, "KEY_UP")
if up_button:
up_button.clicked.connect(self.key_increase_parameter)
down_button = self.findChild(QPushButton, "KEY_DOWN")
if down_button:
down_button.clicked.connect(self.key_decrease_parameter)
@property
def value(self):
return self.Text
def timeout_modify_string_refresh(self) :
line_modify : QLineEdit = self.lineEdit
modify_str : str = line_modify.text()
self.update_modify_string(modify_str)
def update_modify_info(self, modify_str, caption : str) :
if hasattr(self, "label") :
label : QLabel = self.label
label.setText(caption)
self.update_modify_string(modify_str)
def update_modify_string(self, modify_str : str) :
line_modify : QLineEdit = self.lineEdit
line_modify.setText(modify_str)
if self.select_bit < len(modify_str) :
if modify_str[self.select_bit] == ' ':
self.key_enter_process()
# 设置选择从第self.select_bit个字符开始长度为1
line_modify.setSelection(self.select_bit, 1)
def key_increase_parameter(self):
line_modify : QLineEdit = self.lineEdit
text : str = line_modify.text()
if self.select_bit < len(text) :
old_chr = text[self.select_bit]
new_chr = chr_adjust(old_chr, 1)
new_modify_text = modify_string(text, self.select_bit, new_chr)
self.update_modify_string(new_modify_text)
def key_decrease_parameter(self):
line_modify : QLineEdit = self.lineEdit
text : str = line_modify.text()
if self.select_bit < len(text) :
old_chr = text[self.select_bit]
new_chr = chr_adjust(old_chr, -1)
new_modify_text = modify_string(text, self.select_bit, new_chr)
self.update_modify_string(new_modify_text)
def key_enter_process(self):
line_modify : QLineEdit = self.lineEdit
text : str = line_modify.text()
if self.select_bit < len(text) - 1:
self.select_bit += 1
if not str.isdigit(text[self.select_bit]) :
self.key_enter_process()
else :
self.update_modify_string(text)
else :
self.buttonBox.button(QDialogButtonBox.Ok).click()
def key_escape_process(self):
self.buttonBox.button(QDialogButtonBox.Cancel).click()
def dialog_button_ok_clicked(self, button):
if button == self.buttonBox.button(QDialogButtonBox.Ok) :
line_modify : QLineEdit = self.lineEdit
self.Text = line_modify.text()
if __name__ == '__main__':
app = QApplication(sys.argv)
dialog = DialogModifyText(None)
dialog.show()
dialog.exec_()
sys.exit(0)