更新GUI框架

This commit is contained in:
taiyi 2025-11-23 22:52:25 +08:00
parent 4cbcf9becc
commit fed6096314
5 changed files with 2100 additions and 552 deletions

File diff suppressed because it is too large Load Diff

1609
ArticleReplace.py.bak Normal file

File diff suppressed because it is too large Load Diff

38
ArticleReplace.spec Normal file
View File

@ -0,0 +1,38 @@
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['ArticleReplace.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='ArticleReplace',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

3
auth_config.json Normal file
View File

@ -0,0 +1,3 @@
{
"last_license_key": "LGCXVKAH-665RMFLI-WFDH6OJT-CZBCTATA"
}

View File

@ -7,6 +7,7 @@ Python软件授权验证器 (现代化UI版)
3. 现代化深色主题 UI
4. 机器码一键复制
5. 防止后台禁用卡密后仍能使用
6. 验证通过后自动恢复tkinter原始缩放比例
使用方法 (完全兼容旧版):
from auth_validator import AuthValidator
@ -17,9 +18,11 @@ Python软件授权验证器 (现代化UI版)
secret_key="your_secret_key"
)
if not validator.validate():
exit()
sys.exit()
"""
import sys
import os
import json
import time
@ -38,7 +41,7 @@ try:
from tkinter import messagebox
except ImportError:
print("错误: 请先安装UI库 -> pip install customtkinter")
exit(1)
sys.exit(1)
# ==========================================
@ -294,7 +297,7 @@ class AuthWindow(ctk.CTk):
self.verifying = False # 是否正在验证中
# 窗口基础设置
self.title("软件授权验证")
self.title("软件授权验证有问题联系Vtaiyi1224)")
self.geometry("300x350") # 增加高度以容纳服务器地址显示
self.resizable(False, False)
ctk.set_appearance_mode("Dark")
@ -566,6 +569,7 @@ class AuthValidator:
1. 读取保存的卡密如果有
2. 弹出现代化UI窗口并自动验证
3. 验证失败则要求用户重新输入
4. 验证成功后恢复tkinter的原始缩放比例
Returns:
bool: 是否验证成功
"""
@ -575,7 +579,32 @@ class AuthValidator:
# 运行主循环 (这会阻塞代码执行,直到窗口关闭)
app.mainloop()
# 窗口关闭后,如果验证成功,重置 tkinter 的缩放比例
if app.is_verified:
self._reset_tk_scaling()
# 窗口关闭后,检查是否验证成功
return app.is_verified
def _reset_tk_scaling(self):
"""
重置 tkinter DPI 缩放恢复到系统默认值
因为 customtkinter 会修改全局的 tkinter 缩放设置
这样可以确保后续创建的 tkinter 窗口使用正常的尺寸
"""
try:
# 创建一个临时的 tkinter 根窗口来重置缩放
temp_root = tk.Tk()
temp_root.withdraw() # 隐藏窗口
# 重置缩放因子为系统默认值(通常是 1.0
# 这会影响后续所有 tkinter 窗口的尺寸计算
temp_root.tk.call('tk', 'scaling', 1.0)
# 销毁临时窗口
temp_root.destroy()
except Exception as e:
# 如果重置失败,静默处理,不影响主流程
pass
# --- END OF FILE ---