工控上位机控制系统通用UI框架
This commit is contained in:
18
common/allTypesEnum.py
Normal file
18
common/allTypesEnum.py
Normal file
@ -0,0 +1,18 @@
|
||||
# 该文件声明了所有和类型相关的枚举,用于选择
|
||||
|
||||
from enum import Enum
|
||||
|
||||
# os平台类型
|
||||
class EOSType(Enum):
|
||||
WINDOW = 0,
|
||||
MACOS = 1,
|
||||
LINUX = 2,
|
||||
|
||||
# 功能子页面枚举
|
||||
class ESubPageType(Enum):
|
||||
AUTOPROC = 0,
|
||||
DEVDEBUG = 1,
|
||||
PARASETTING = 2,
|
||||
DATAQUERY = 3,
|
||||
RECIPEMANAGE = 4,
|
||||
USERMANAGE = 5,
|
||||
17
common/dbORMType.py
Normal file
17
common/dbORMType.py
Normal file
@ -0,0 +1,17 @@
|
||||
# 该文件定义了和db各个表字段对应的结构体类型
|
||||
|
||||
# 配方管理信息表
|
||||
stuTbRecipe = {
|
||||
'f_proc_name' : 'none',
|
||||
'f_create_time' : 'none',
|
||||
'f_update_time' : 'none',
|
||||
'f_created_by' : 'none',
|
||||
}
|
||||
|
||||
# 用户管理信息表
|
||||
stuTbUser = {
|
||||
'f_user_id' : 'None',
|
||||
'f_user_type' : 0,
|
||||
'f_password' : 'None',
|
||||
'f_create_time' : 'None',
|
||||
}
|
||||
49
common/generalFunc.py
Normal file
49
common/generalFunc.py
Normal file
@ -0,0 +1,49 @@
|
||||
# 该模块定义了一些通用的功能接口
|
||||
|
||||
# 声明全局功能类
|
||||
class CCommon:
|
||||
# 获取屏幕的分辨率
|
||||
@staticmethod
|
||||
def fnGetScreenRate() -> tuple[int, int]:
|
||||
import pyautogui
|
||||
nScreenWidth, nScreenHeight = pyautogui.size()
|
||||
return nScreenWidth, nScreenHeight
|
||||
|
||||
# 获取当前时间,'xxxx/xx/xx xx:xx:xx'
|
||||
@staticmethod
|
||||
def fnGetCurrentTime() -> str:
|
||||
from datetime import datetime
|
||||
# 获取当前本地时间(datetime对象)
|
||||
local_time = datetime.now()
|
||||
# 格式化输出为字符串
|
||||
return local_time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# 判断内容是否符合限制要求
|
||||
@staticmethod
|
||||
def fnCheckInputValid(key, modifier, key_char) -> bool:
|
||||
# 允许的控制键:退格、删除、方向键、Ctrl+A/C/V/X(全选/粘贴/剪切)
|
||||
allowed_control_keys = (
|
||||
0x01000003, # 退格
|
||||
0x01000007, # 删除
|
||||
0x01000012, # 左方向键
|
||||
0x01000014, # 右方向键
|
||||
0x01000013, # 上方向键
|
||||
0x01000015, # 下方向键
|
||||
0x01000010, # 首页键
|
||||
0x01000011, # 尾页键
|
||||
)
|
||||
# 允许的功能快捷键(Ctrl+A/C/V/X)
|
||||
if modifier == 0x04000000: # Qt.ControlModifier
|
||||
if key in (0x41, 0x43, 0x56, 0x58): # [Qt.Key_A, Qt.Key_C, Qt.Key_V, Qt.Key_X]:
|
||||
return True
|
||||
# 放行控制键
|
||||
if key in allowed_control_keys:
|
||||
return True
|
||||
# 允许的可打印字符:大小写字母、数字、下划线
|
||||
# 获取按键对应的字符
|
||||
if key_char:
|
||||
# 判断字符是否符合规则:字母(大小写)、数字、下划线
|
||||
if key_char.isalnum() or key_char == "_":
|
||||
return True
|
||||
# 其他按键一律拦截(返回True表示不处理该事件)
|
||||
return False
|
||||
Reference in New Issue
Block a user