from PIL import Image, ImageTk
import tkinter as tk
from tkinter import ttk
from tkinter import Toplevel, messagebox
import threading
import requests
import os
import getpass
import subprocess
import zipfile
from tkinter import messagebox
import sys
from encoded_images import *
import io
import base64
import ctypes
import webbrowser
import socket
import re
from ping3 import ping, verbose_ping
import time
from concurrent.futures import ThreadPoolExecutor
from tqdm import tqdm
def check_ping(target, count=4, timeout=2):
"""检查目标是否可达,返回 True(至少成功一次)或 False(全部失败)"""
success = False
for _ in range(count):
try:
latency = ping(target, timeout=timeout)
if latency is not None and latency is not False:
success = True
return success
except Exception:
pass
return success
# def test_network_connection():
# time.sleep(0.2) # 暂停0.2秒钟
# try:
# latency = ping('192.54.2.134') # 获取延迟时间,单位为微秒
# time.sleep(1) # 暂停1秒钟
# if latency is None or latency == False:
# pass
# return False
# except Exception as err:
# pass
# return False
# # print(latency)
# if latency:
# return True
# else:
# return False
#
#
# connection_status=test_network_connection() #是否联网
# connection_status = check_ping('192.54.2.134', count=5, timeout=2) #NPI里面 没有放行 192.54.2.134 的 imcp,所以ping不通
connection_status = check_ping('192.54.2.2', count=5, timeout=2)
if connection_status:
print("电脑具有网络") # 弹出窗口示例
else:
ctypes.windll.user32.MessageBoxW(0, "电脑没有网络或未连上公司内网,无法打开软件窗口!", "提示", 0) # 弹出窗口示例
sys.exit()
ctypes.windll.user32.MessageBoxW(0, "打开帮助文档!", "提示", 0) # 弹出窗口示例
def on_configure(event):
# 更新scrollregion以适应所有内容
canvas.configure(scrollregion=canvas.bbox('all'))
username = getpass.getuser()
# if getattr(sys, 'frozen', False):
# # 如果是通过PyInstaller冻结的(打包成exe)
# current_dir = os.path.dirname(sys.executable)
# else:
# # 如果是正常的python脚本运行
# current_dir = os.path.dirname(os.path.abspath(__file__))
# 创建主窗口
root = tk.Tk()
root.title(r"安装软件助手,所有软件被下载至 桌面\download_From_Self_Install 目录下,不能同时下载2个或2个以上的软件")
# 设置窗口大小(可选)
root.geometry("1000x690")
# 创建一个 Canvas 小部件
canvas = tk.Canvas(root)
canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
# 添加 Scrollbar 小部件并与 Canvas 关联
scrollbar = ttk.Scrollbar(root, orient=tk.VERTICAL, command=canvas.yview)
scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
# 配置 Canvas 使用 scrollbar
canvas.configure(yscrollcommand=scrollbar.set)
# 创建一个 Frame 放在 Canvas 上,并让所有的按钮都放在这个 Frame 中
parent_frame = tk.Frame(canvas)
# 创建一个窗口对象并添加到 Canvas 中
canvas.create_window((0, 0), window=parent_frame, anchor='nw')
# 当 Frame 的大小改变时,调整 Canvas 的 scrollregion
parent_frame.bind('<Configure>', on_configure)
child_frame = tk.Frame(parent_frame)
child_frame.pack(fill=tk.BOTH, expand=True) # 将 child_frame 填充到 parent_frame 中
def base64_to_image(image_pre):
print(image_pre)
base64_str = globals()[image_pre]
image_data = base64.b64decode(base64_str)
image = Image.open(io.BytesIO(image_data))
tk_image = ImageTk.PhotoImage(image)
return tk_image
# 下面的代码对 解压后的中文文件名为乱码
# def unzip_file(zip_file_path, extract_to):
# with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
# # 确保覆盖已存在的文件
#
# for member in zip_ref.namelist():
# zip_ref.extract(member, path=extract_to, pwd=None)
def unzip_file(zip_file_path, extract_to):
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
# 遍历压缩包内的所有文件
for info in zip_ref.infolist():
# 尝试使用'utf-8'解码文件名
try:
# 有些ZIP文件可能使用utf-8编码
info.filename = info.filename.encode('cp437').decode('utf-8')
except UnicodeDecodeError:
# 如果失败,则尝试使用'gbk'解码(适用于简体中文环境)
try:
info.filename = info.filename.encode('cp437').decode('gbk')
except UnicodeDecodeError:
pass # 如果两种编码都失败,则保持原样
# 解压文件
zip_ref.extract(info, path=extract_to)
# 下载函数 无进度条
def download_file(url, local_filename):
with requests.get(url, stream=True) as r:
r.raise_for_status()
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=65536):
f.write(chunk)
return local_filename
# 下载函数 有进度条
def download_file_jingdutiao(url, save_path):
response = requests.get(url, stream=True)
total_size = int(response.headers.get('content-length', 0))
with open(save_path, 'wb') as file:
downloaded_size = 0
for data in response.iter_content(chunk_size=1024*1024):
if data:
file.write(data)
downloaded_size += len(data)
progress = (downloaded_size / total_size) * 100
update_progress(progress)
global close_button
if save_path.endswith(".zip"):
messagebox.showinfo("解压ZIP", "请等待程序解压ZIP,解压完在后,安装按钮自动生效")
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
unzip_file(save_path, download_dir)
close_button.config(state=tk.NORMAL)
def download_range(url, start, end, temp_file, progress_data):
headers = {"Range": f"bytes={start}-{end}"}
with requests.get(url, headers=headers, stream=True) as r:
with open(temp_file, "wb") as f:
for chunk in r.iter_content(chunk_size=1024 * 1024): # 1M
if chunk:
f.write(chunk)
size = len(chunk)
with progress_data["lock"]:
progress_data["downloaded"] += size
# 用本函数来替代 download_file_jingdutiao
def download_file_multithread(url, filename,installation_word, num_threads=4):
resp = requests.head(url)
file_size = int(resp.headers.get("Content-Length", 0))
if file_size == 0:
raise Exception("无法获取文件大小")
# 分块区间
part_size = file_size // num_threads
ranges = []
for i in range(num_threads):
start = i * part_size
end = (i + 1) * part_size - 1 if i < num_threads - 1 else file_size - 1
ranges.append((start, end))
temp_files = [f"{filename}.part{i}" for i in range(num_threads)]
import threading
progress_data = {"downloaded": 0, "lock": threading.Lock(), "done": False}
start_time = time.time()
update_ui(0, file_size, progress_data, start_time,installation_word)
# 下载线程
def run_download():
with ThreadPoolExecutor(max_workers=num_threads) as executor:
futures = []
for i, (start, end) in enumerate(ranges):
futures.append(executor.submit(download_range, url, start, end, temp_files[i], progress_data))
for f in futures:
f.result()
progress_data["done"] = True
# 合并文件
with open(filename, "wb") as outfile:
for temp_file in temp_files:
with open(temp_file, "rb") as infile:
outfile.write(infile.read())
os.remove(temp_file)
if filename.endswith(".zip"):
messagebox.showinfo("解压ZIP", "请等待程序解压ZIP,解压完在后,安装按钮自动生效")
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
unzip_file(filename, download_dir)
update_ui(100, file_size, progress_data,start_time,installation_word)
threading.Thread(target=run_download, daemon=True).start()
# 更新进度条和进度百分比
def update_progress(progress):
global progress_bar
global progress_label
progress_bar['value'] = progress
progress_label.config(text=f'Progress: {progress:.2f}%')
root.update_idletasks()
# 更新进度条和进度百分比
def update_ui(progress,file_size,progress_data, start_time,installation_word):
global progress_bar
global progress_label
if not progress_data["done"]:
with progress_data["lock"]:
downloaded = progress_data["downloaded"]
progress = downloaded / file_size * 100
elapsed = time.time() - start_time
speed = downloaded / 1024 / 1024 / elapsed if elapsed > 0 else 0
remaining = (file_size - downloaded) / (speed * 1024 * 1024) if speed > 0 else 0
progress_bar['value'] = progress
progress_label.config(text=f'Progress: {progress:.2f}% | 速度: {speed:.2f} MB/s | 剩余: {remaining:.1f}s \n')
# print(progress)
# update_ui(progress,file_size,progress_data)
# 设置下一次更新,而不是递归调用 200是200毫秒
root.after(200, update_ui,progress, file_size, progress_data, start_time,installation_word)
#print(progress)
#root.update_idletasks()
else:
# 下载完成时显示100%
progress_bar['value'] = 100
progress_label.config(text=f"100.00%下载完成,请等两秒点击\"{installation_word}\";\n若安装出现错误,点击\"已下载 {installation_word}\"")
global close_button
close_button.config(state=tk.NORMAL)
# 开始下载ioioiuiu
def start_download(program_url, needed_admin, spc_url,installation_word):
global download_button
download_button.config(state=tk.DISABLED)
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
if not os.path.exists(download_dir):
os.makedirs(download_dir)
local_RunAsSpc_filename = f"{download_dir}" + "/" + "RunAsSpc.exe"
web_RunAsSpc_url = url_root + "/" + "RunAsSpc.exe" # 下载RunAsSpc
download_file(web_RunAsSpc_url, local_RunAsSpc_filename)
# local_RunAsSpcAdmin_filename = f"{download_dir}" + "/" + "RunAsSpcAdmin.exe"
# web_RunAsSpcAdmin_url = url_root + "/" +"RunAsSpcAdmin.exe" # 下载RunAsSpcAdmin
# download_file(web_RunAsSpcAdmin_url, local_RunAsSpcAdmin_filename)
print(spc_url)
if spc_url:
local_spc_filename = f"{download_dir}" + "/" + spc_url
web_spc_url = url_root + "/" + spc_url # 下载RunAsSpcAdmin
download_file(web_spc_url, local_spc_filename)
save_path = download_dir + "/" + program_url # 替换为实际的保存路径
url = url_root + "/" + program_url
download_thread = threading.Thread(target=download_file_multithread, args=(url, save_path,installation_word))
download_thread.start()
def create_new_window(needed_admin, program_url, spc_url, text, installation_word, usedbclick_execute):
new_window = Toplevel(root)
new_window.title(f"下载 {text} 进度")
new_window.geometry("330x240")
global progress_bar
# 创建进度条
progress_bar = ttk.Progressbar(new_window, orient='horizontal', length=300, mode='determinate')
progress_bar.pack(pady=20)
global progress_label
# 创建进度百分比标签
progress_label = tk.Label(new_window, text="Progress: 0.00% \n")
progress_label.pack(pady=10)
frame = tk.Frame(new_window)
frame.pack(pady=10)
global download_button
# 创建开始下载按钮
download_button = tk.Button(frame, text="开始下载",
command=lambda: start_download(program_url, needed_admin, spc_url,installation_word))
download_button.grid(column=0, row=0, padx=10, pady=2)
# 添加一个安装按钮
def install_software():
print(usedbclick_execute)
print(needed_admin)
if usedbclick_execute:
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
os.startfile(download_dir)
new_window.destroy()
else:
messagebox.showinfo("等待软件安装", f"请等待安装......")
# 指定要执行的命令及其参数 //假如
if not needed_admin: # 不是管理员
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
local_program_filename = f"{download_dir}" + "/" + program_url
command = [
f"{local_program_filename}",
]
print(f"{program_url}")
print(program_url)
print(local_program_filename)
else:
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
local_RunAsSpc_filename = f"{download_dir}" + "/" + "RunAsSpc.exe"
local_spc_filename = f"{download_dir}" + "/" + spc_url
# local_spc_filename = local_spc_filename.encode('gb2312', errors='ignore')
# print("AAA")
# print(local_spc_filename)
command = [
f"{local_RunAsSpc_filename}",
f'/cryptfile:{local_spc_filename}', # 确保反斜杠被正确转义
'/quiet' # 如果有问题的话,就注释掉它,会报错,可以查出错误的原因
]
try:
# 执行命令
result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# 打印标准输出和错误输出
# print("Output:", result.stdout.decode())
# print("Error:", result.stderr.decode())
print("Output:", result.stdout.decode('utf-8', errors='ignore'))
print("Output:", result.stderr.decode('utf-8', errors='ignore'))
except subprocess.CalledProcessError as e:
print(f"An error occurred while executing the command: {e}")
# print("Output:", e.stdout.decode())
# print("Error:", e.stderr.decode())
print("Output:", e.stdout.decode('utf-8', errors='ignore'))
print("Error:", e.stderr.decode('utf-8', errors='ignore'))
global downloading
downloading = 0 # 关闭时那么 正在下载 的值为 0
new_window.destroy()
def close_new_window():
global downloading
downloading = 0 # 关闭时那么 正在下载 的值为 0
new_window.destroy()
global close_button
close_button = tk.Button(frame, text=f"{installation_word}", state=tk.DISABLED, command=install_software)
close_button.grid(column=1, row=0, padx=10, pady=2)
download_dir = f"C:/Users/{username}/Desktop/download_From_Self_Install"
local_program_filename = f"{download_dir}" + "/" + program_url
# global close_button1
if os.path.isfile(local_program_filename):
close_button1 = tk.Button(frame, text=f"已下载 {installation_word}", command=install_software)
close_button1.grid(column=2, row=0, padx=10, pady=2)
else:
close_button1 = tk.Button(frame, text=f"已下载 {installation_word}", state=tk.DISABLED,
command=install_software)
close_button1.grid(column=2, row=0, padx=10, pady=2)
new_window.protocol("WM_DELETE_WINDOW", close_new_window)
# 定义按钮点击回调函数
def button_click(button_number, needed_admin, program_url, spc_url, text, installation_word, usedbclick_execute):
global downloading
if downloading == 1:
messagebox.showinfo("一个程序正在下载或运行中", "一个程序正在下载或运行中......请等待!")
else:
# 创建新窗口,,让 downloading == 1
create_new_window(needed_admin, program_url, spc_url, text, installation_word, usedbclick_execute)
downloading = 1
# if needed_admin == False:
# print(f"按钮 is {needed_admin} !")
# else:
# print(f"按钮 is {needed_admin} !")
def get_local_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 80)) # 这是DNS服务器的 UDP 80端口
local_ip = s.getsockname()[0]
s.close()
return local_ip
def get_ips_by_scope(scope):
if scope == 'ccc_qqqqq':
# 前面是无线网段范围,见faq网站的代码 '192.54.192.', '192.54.193.', '192.54.194.', '192.54.195.','192.54.208.', '192.54.209.', '192.54.2192.', '192.54.211.',
# '192.169.192.', '192.169.193.', '192.169.194.', '192.169.195.', '192.54.224.', '192.54.225.', '192.54.164.',
# 后面是有线网段范围,见faq网站的代码 '192.54.70.', '192.54.71.','192.54.92.', '192.169.40.', '192.169.41.'
# 再后面是 V 区 无线网段的范围
# 再后面是 V 区 有线网段的范围
return {'192.54.192.', '192.54.193.', '192.54.194.', '192.54.195.', '192.54.208.', '192.54.209.', '192.54.2192.',
'192.54.211.',
'192.169.192.', '192.169.193.', '192.169.194.', '192.169.195.', '192.54.224.', '192.54.225.', '192.54.164.',
'192.54.70.', '192.54.71.', '192.54.92.', '192.169.40.', '192.169.41.'
'192.196.182.', '192.196.183.', # C区无线
'192.196.170.', # C区有线
'192.196.192', '192.196.193', # D区无线
'192.196.40', # D区有线
}
elif scope == 'ccc_uuu':
# 前面是无线网段范围,见faq网站的代码 '192.54.226.', '192.54.227.'
# 后面是有线网段范围,见faq网站的代码 '192.169.206.'
return {'192.54.226.', '192.54.227.',
'192.169.206.',
'192.54.133.',
'192.169.61.'
}
elif scope == 'ccc_eeeee':
# 前面是无线网段范围,见faq网站的代码 '192.54.200.', '192.54.201.', '192.54.202.', '192.54.203.', '192.54.204.', '192.54.205.', '192.54.206.', '192.54.207.',
# 后面是有线网段范围,见faq网站的代码 '192.54.116.', '192.54.117.', '192.54.118.', '192.54.119.'
return {'192.54.200.', '192.54.201.', '192.54.202.', '192.54.203.', '192.54.204.', '192.54.205.', '192.54.206.',
'192.54.207.',
'192.54.116.', '192.54.117.', '192.54.118.', '192.54.119.'
}
elif scope == 'ccc_wwwww':
# 前面是无线网段范围,见faq网站的代码 '192.54.248.', '192.54.249.', '192.54.250.', '192.54.251.',
# '192.169.208.', '192.169.209.', '192.169.2192.', '192.169.211.'
# 后面是有线网段范围,见faq网站的代码 '192.54.100.', '192.54.101.', '192.54.102.', '192.54.103.', '192.54.148.', '192.54.149.', '192.54.150.', '192.54.151.',
# '192.169.48.', '192.169.49.', '192.169.50.', '192.169.51.'
return {'192.54.248.', '192.54.249.', '192.54.250.', '192.54.251.',
'192.169.208.', '192.169.209.', '192.169.2192.', '192.169.211.',
'192.54.100.', '192.54.101.', '192.54.102.', '192.54.103.', '192.54.148.', '192.54.149.', '192.54.150.',
'192.54.151.',
'192.169.48.', '192.169.49.', '192.169.50.', '192.169.51.'
'192.196.186', '192.196.187', # 可能C区MP
'192.196.196', '192.196.197', # 可能D区MP
}
elif scope == 'ccc_rrrrr':
# 前面是无线网段范围,见faq网站的代码 '192.54.236.', '192.54.237.', '192.54.238.', '192.54.239.'
# '192.54.115.'
return {'192.54.236.', '192.54.237.', '192.54.238.', '192.54.239.',
'192.54.115.'
}
elif scope == 'ccc_ttttt':
# 前面是无线网段范围,见faq网站的代码 '192.54.248.', '192.54.249.', '192.54.250.', '192.54.251.',
# '192.169.208.', '192.169.209.', '192.169.2192.', '192.169.211.'
# 后面是有线网段范围,见faq网站的代码 '192.54.100.', '192.54.101.', '192.54.102.', '192.54.103.', '192.54.148.', '192.54.149.', '192.54.150.', '192.54.151.',
# '192.169.48.', '192.169.49.', '192.169.50.', '192.169.51.'
return {'192.54.244.', '192.54.245.', '192.54.246.', '192.54.247.',
'192.169.212.', '192.169.213.',
'192.54.104.', '192.54.152.',
'192.169.52.'
}
elif scope == 'jsnpi_oa':
# 有线网段范围,见faq网站的代码 '192.54.120.'
return {'192.54.120.',
}
elif scope == 'jsmp_oa':
# 有线网段范围,见faq网站的代码 '192.54.105.',
# '192.54.153.',
# '192.169.53.'
return {'192.54.105.',
'192.54.153.',
'192.169.53.'
}
return set()
def get_scope(scopes=['ALL']):
if scopes == ['ALL']:
return "1"
global connection_status
if not connection_status and scopes != ['ALL']: # 假如连接失败的话,就返回 0
return "0"
result = set()
for scope in scopes:
result = result | get_ips_by_scope(scope)
local_ip = get_local_ip()
print("local_ip")
print(local_ip)
# messagebox.showinfo("解压ZIP", local_ip)
local_ip_prefix = re.sub(r'\.\d+$', '.', local_ip)
# time.sleep(0.2) # 暂停0.2秒钟
if local_ip_prefix in result:
# messagebox.showinfo("yes", "yes")
# time.sleep(1) #暂停1秒钟
return "1"
return "0"
list_softwares = [
{"img_url": "img/v.png", "program_url": "get_computername.exe", "spc_url": "",
"text": "查看计算机名", "needed_admin": False, "installation_word": "查看", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/m.png", "program_url": "modify_computer_name.exe",
"spc_url": "modify_computer_name.spc", "text": "修改计算机名", "needed_admin": True, "installation_word": "修改",
"usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/ip_mac.png", "program_url": "local_ip_mac.exe", "spc_url": "", "text": "查看 ip mac",
"needed_admin": False, "installation_word": "查看", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hosts.png", "program_url": "replace_hosts_zhong.exe", "spc_url": "replace_hosts_zhong.spc",
"text": "替换Hosts", "needed_admin": True, "installation_word": "替换", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hosts.png", "program_url": "replace_hosts_zhong_new.exe", "spc_url": "replace_hosts_zhong_new.spc",
"text": "替换Hosts新版", "needed_admin": True, "installation_word": "替换", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hosts.png", "program_url": "lxpc_update_hosts.exe", "spc_url": "lxpc_update_hosts.spc",
"text": "立联更新Hosts", "needed_admin": True, "installation_word": "替换", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/manually_wifi.png", "program_url": "set_connect_wifi.exe", "spc_url": "",
"text": "手动连接wifi", "needed_admin": False, "installation_word": "连接", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/bgxns.png", "program_url": "bangongxiaonenshou.exe", "spc_url": "", "text": "办公小能手",
"needed_admin": False, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/del_user.png", "program_url": "deleteUsers.bat", "spc_url": "deleteUsers.spc",
"text": "删除用户", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/mes.png", "program_url": "anzhuang_mes.bat", "spc_url": "", "text": "安装MES",
"needed_admin": False, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/outlook.png", "program_url": "email_re_match_compatible_count.bat", "spc_url": "",
"text": "配置邮箱(兼容版本)", "needed_admin": False, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/outlook.png", "program_url": "xingban_email_re_match_count.exe", "spc_url": "",
"text": "配置新版邮箱", "needed_admin": False, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/outlook2016.png", "program_url": "2016_email_re_match_count.exe", "spc_url": "",
"text": "配置2016邮箱", "needed_admin": False, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/wcdq.png", "program_url": "lixunwangzhidaquang.bat", "spc_url": "", "text": "立讯常用网址",
"needed_admin": False, "installation_word": "打开", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/test_network.png", "program_url": "test_ip_port_connection.exe", "spc_url": "",
"text": "测试网络连通", "needed_admin": False, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/uninstall_chrome.png", "program_url": "uninstall_chrome.bat", "spc_url": "uninstall_chrome.spc",
"text": "卸载chrome", "needed_admin": True, "installation_word": "卸载", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/chrome.png", "program_url": "GoogleChromev120.msi", "spc_url": "GoogleChromev120.spc",
"text": "安装chrome120", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/chrome.png", "program_url": "GoogleChrome129.0.6668.59Stablex64.msi",
"spc_url": "GoogleChrome129.0.6668.59Stablex64.spc", "text": "安装chrome129", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/firefox.png", "program_url": "Firefox-full-latest-win64.exe",
"spc_url": "Firefox-full-latest-win64.spc", "text": "安装firefox116", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/opera.png", "program_url": "Opera_117.0.5408.35_Setup.exe",
"spc_url": "Opera_117.0.5408.35_Setup.spc", "text": "安装Opera117", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/edge.png", "program_url": "MicrosoftEdgeEnterpriseX64.msi",
"spc_url": "MicrosoftEdgeEnterpriseX64.spc", "text": "安装Edge", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/cer.png", "program_url": "start_bud_cer.zip",
"spc_url": "start_bud_cer.spc", "text": "安装bud证书", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/py.png", "program_url": "python-3.192.6-amd64.exe", "spc_url": "python-3.192.6-amd64.spc",
"text": "安装Python", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/pycharm.png", "program_url": "pycharm-community-2022.2.1.exe",
"spc_url": "pycharm-community-2022.2.1.spc", "text": "安装Pycharm", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/rdp_oa.png", "program_url": "OA.rdp", "spc_url": "", "text": "安装远程OA", "needed_admin": False,
"installation_word": "打开文件夹", "usedbclick_execute": True, "scope": get_scope()},
{"img_url": "img/local_sap.png", "program_url": "1.bbbb_SAPGUI.exe", "spc_url": "1.bbbb_SAPGUI.spc",
"text": "安装本地SAP", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/rdp_sap.png", "program_url": "SAP.rdp", "spc_url": "", "text": "安装远程SAP",
"needed_admin": False, "installation_word": "打开文件夹", "usedbclick_execute": True, "scope": get_scope()},
{"img_url": "img/sougou_pinyin.png", "program_url": "sogou_pinyin_104a.exe", "spc_url": "sogou_pinyin_104a.spc",
"text": "安装搜狗拼音", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/sougou_wubi.png", "program_url": "sogou_wubi_31a.exe", "spc_url": "sogou_wubi_31a.spc",
"text": "安装搜狗五笔", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/ftp.png", "program_url": "FTP.exe", "spc_url": "FTP.spc", "text": "安装FTP", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/ipguard.png", "program_url": "JS-192.54.2.8-4.84-ipguard.exe",
"spc_url": "JS-192.54.2.8-4.84-ipguard.spc", "text": "安装ipguard", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/dacs.png", "program_url": "DACS_8046_last.exe", "spc_url": "DACS_8046_last.spc",
"text": "安装沙箱", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/pdf.png", "program_url": "PDF.exe", "spc_url": "PDF.spc", "text": "安装PDF", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/anaconda.png", "program_url": "Anaconda3-2022.10-Windows-x86_64.exe",
"spc_url": "Anaconda3-2022.10-Windows-x86_64.spc", "text": "安装Anaconda3", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/anaconda.png", "program_url": "set_anaconda_env.exe", "spc_url": "set_anaconda_env.spc",
"text": "配置Anaconda3", "needed_admin": True, "installation_word": "配置", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/winrar.png", "program_url": "winrar-x64-561scp.exe", "spc_url": "winrar-x64-561scp.spc",
"text": "安装WinRAR", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/seven_zip.png", "program_url": "7z2409.exe", "spc_url": "7z2409.spc",
"text": "安装7zip", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/youdao.png", "program_url": "YoudaoDictSetup.exe", "spc_url": "YoudaoDictSetup.spc",
"text": "安装有道", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/youdao.png", "program_url": "get_youdao_cidian_to_local.exe", "spc_url": "",
"text": "获取有道离线词典", "needed_admin": False, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/reset_net.png", "program_url": "reset_net.exe", "spc_url": "reset_net.spc", "text": "重置网络",
"needed_admin": True, "installation_word": "重置", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/jianying.png", "program_url": "Jianying_pro_2_6_0_7223_jianyingpro_baidupz.exe",
"spc_url": "Jianying_pro_2_6_0_7223_jianyingpro_baidupz.spc", "text": "安装剪映", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/office.png", "program_url": "Office2021.zip", "spc_url": "Office2021.spc", "text": "office2021",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/jihuo_win_qqqqq.png", "program_url": "office.bat", "spc_url": "office.spc",
"text": "激活_win_qqqqq", "needed_admin": True, "installation_word": "激活", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/libreoffice.png", "program_url": "LibreOffice_7.2.7_Win_x64.msi",
"spc_url": "LibreOffice_7.2.7_Win_x64.spc", "text": "安装LibreOffice", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/wps.png", "program_url": "WPS_Setup_21915.exe",
"spc_url": "WPS_Setup_21915.spc", "text": "安装WPS", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope(['ccc_qqqqq', 'ccc_uuu'])},
{"img_url": "img/qywx.png", "program_url": "WeCom.exe", "spc_url": "WeCom.spc",
"text": "安装企业微信", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope(['ccc_qqqqq', 'ccc_uuu'])},
{"img_url": "img/wx.png", "program_url": "WeChatWin.exe", "spc_url": "WeChatWin.spc",
"text": "安装微信", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/bgrj.png", "program_url": "EportClientSetup_V1.5.54.exe",
"spc_url": "EportClientSetup_V1.5.54.spc",
"text": "电子口岸控件1.5.53", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/haiguan_printer.png", "program_url": "printer.exe", "spc_url": "printer.spc",
"text": "海关打印控件新版", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/ruwen.png", "program_url": "ru_wen_ce_shi_ruan_jian.zip", "spc_url": "ru_wen_ce_shi_ruan_jian.spc",
"text": "安装炉温测试",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/FSCapture.png", "program_url": "FSCapture6.9.zip", "spc_url": "", "text": "FSCapture6.9",
"needed_admin": False, "installation_word": "打开文件夹", "usedbclick_execute": True, "scope": get_scope()},
{"img_url": "img/webex.png", "program_url": "Webex.exe", "spc_url": "Webex.spc", "text": "安装Webex",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/luxai.png", "program_url": "LuxAI-1.1.2.exe", "spc_url": "", "text": "安装Lux Ai",
"needed_admin": False, "installation_word": "安装", "usedbclick_execute": True,
"scope": get_scope(['ccc_qqqqq', 'ccc_uuu', 'ccc_wwwww', 'ccc_ttttt'])},
{"img_url": "img/xie_zai_gong_ju.png", "program_url": "xie_zai_gong_ju.exe", "spc_url": "xie_zai_gong_ju.spc",
"text": "卸载工具",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/tenxun_meeting.png",
"program_url": "TencentMeeting_0300000000_3.31.2.441_x86_64.publish.officialwebsite.exe",
"spc_url": "TencentMeeting_0300000000_3.31.2.441_x86_64.publish.officialwebsite.spc", "text": "安装腾讯会议",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/aTrustInstaller.png", "program_url": "aTrustInstaller.exe", "spc_url": "aTrustInstaller.spc",
"text": "零信任VPN",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope(['ccc_qqqqq'])},
{"img_url": "img/asiainfo.png", "program_url": "agent_standard_x64.msi", "spc_url": "agent_standard_x64.spc",
"text": "亚信办公杀毒",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/san_liu_ling.png", "program_url": "Ent_360EPP421800691[192.54.2.61-8080]-W.exe",
"spc_url": "Ent_360EPP421800691[192.54.2.61-8080]-W.spc", "text": "360杀毒",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/meitu.png", "program_url": "xiuxiu64_setup.exe", "spc_url": "xiuxiu64_setup.spc",
"text": "美图秀秀", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/everything.png", "program_url": "Everything-1.4.1.1002.x64-Setup.exe",
"spc_url": "Everything-1.4.1.1002.x64-Setup.spc",
"text": "Everything", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/minicad.png", "program_url": "MiniCADSee_tj1_X64.exe", "spc_url": "MiniCADSee_tj1_X64.spc",
"text": "迷你CAD查看 ", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/odaviewer.png", "program_url": "ODAViewer_QT6_vc16_amd64dll_26.7.msi", "spc_url": "ODAViewer_QT6_vc16_amd64dll_26.7.spc",
"text": "ODA CAD查看", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/treesize.png", "program_url": "TreeSizeFreeSetup.exe", "spc_url": "TreeSizeFreeSetup.spc",
"text": "分析磁盘treesize", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/pdf24.png", "program_url": "pdf24-creator-11.27.0-x64.exe", "spc_url": "pdf24-creator-11.27.0-x64.spc",
"text": "pdf24", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/zysz.png", "program_url": "Touchpad-IKVD09AF_k43c_80.exe",
"spc_url": "Touchpad-IKVD09AF_k43c_80.spc", "text": "双指驱动(k43c-80)", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/zysz2.png", "program_url": "zhaoyang_K4e_IML_touch_udated.exe",
"spc_url": "zhaoyang_K4e_IML_touch_udated.spc", "text": "K4e-IML触摸板", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/Dell_3400.png", "program_url": "DELL3400_Audio_drive.exe", "spc_url": "DELL3400_Audio_drive.spc",
"text": "戴尔3400声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/Dell_3450.png", "program_url": "DELL3450_Audio_drive.exe", "spc_url": "DELL3450_Audio_drive.spc",
"text": "戴尔3450声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/Dell_3480.png", "program_url": "DELL3480_Audio_drive.exe", "spc_url": "DELL3480_Audio_drive.spc",
"text": "戴尔3480声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/Dell_35192.png", "program_url": "Dell3510_Audio_drive.exe", "spc_url": "Dell3510_Audio_drive.spc",
"text": "戴尔3510声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_audio.png", "program_url": "sp154228_hp_240_9g_yingping_drive.exe",
"spc_url": "sp154228_hp_240_9g_yingping_drive.spc", "text": "惠普240G9声卡", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_audio_new.png", "program_url": "sp154228_hp_240_9g_yingping_drive2.exe",
"spc_url": "sp154228_hp_240_9g_yingping_drive2.spc", "text": "惠普240G9声卡(新)", "needed_admin": True,
"installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_348_g7.png", "program_url": "HP_348_Audio_Drive.exe", "spc_url": "HP_348_Audio_Drive.spc",
"text": "惠普348G7声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_348_g7_new.png", "program_url": "HP_348_Audio_Drive2.exe", "spc_url": "HP_348_Audio_Drive2.spc",
"text": "惠普348G7声卡(新)", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_440_g8.png", "program_url": "sp154105_440_G8_audio.exe", "spc_url": "sp154105_440_G8_audio.spc",
"text": "惠普440G8声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_640_g11.png", "program_url": "HP_640_G11_Audio_Drive.exe",
"spc_url": "HP_640_G11_Audio_Drive.spc",
"text": "惠普640G11声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_book_15.png", "program_url": "sp154860.exe", "spc_url": "sp154860.spc",
"text": "惠普Book15声卡",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/zhaoyang_X7_14_IMH.png", "program_url": "zhaoyang_X7_14_IMH_Audio_drive.exe",
"spc_url": "zhaoyang_X7_14_IMH_Audio_drive.spc",
"text": "X7-14 IMH声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/zhaoyang_X5_14_IML1.png", "program_url": "audio-ULT1047FYTGQ3SF0.exe",
"spc_url": "audio-ULT1047FYTGQ3SF0.spc",
"text": "X5-14 IML声卡1", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/zhaoyang_X5_14_IML2.png", "program_url": "isst-ULT1077FC78VVSF0.exe",
"spc_url": "isst-ULT1077FC78VVSF0.spc",
"text": "X5-14 IML声卡2", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/zhaoyang_K4e_ITL.png", "program_url": "audio-ARTA05AF20JBUPC0.exe",
"spc_url": "audio-ARTA05AF20JBUPC0.spc",
"text": "K4e-ITL声卡", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/xiaoxing_Air_14_2021_ITL.png", "program_url": "audio-37S50A0FDQ79NEB0.exe",
"spc_url": "audio-37S50A0FDQ79NEB0.spc",
"text": "Air-14 2021 ITL", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/hp_1216_printer.png", "program_url": "HP_LaserJet_M1216nf_MFP.exe",
"spc_url": "HP_LaserJet_M1216nf_MFP.spc", "text": "惠普打印机 1216",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_11_12_printer.png", "program_url": "HP_M1130_M1210_MFP_Full_Solution-v20180815-10158769_1.exe",
"spc_url": "HP_M1130_M1210_MFP_Full_Solution-v20180815-10158769_1.spc", "text": "惠普 11 12完整版",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_M127_M128_printer.png", "program_url": "HP_LJPro_MFP_M127-M128_drv-only_15309.exe",
"spc_url": "HP_LJPro_MFP_M127-M128_drv-only_15309.spc", "text": "惠普打印机127_128",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_M127_M128_printer.png", "program_url": "LJPro_MFP_M127-M128_full_solution_23199.22.21.exe",
"spc_url": "LJPro_MFP_M127-M128_full_solution_23199.22.21.spc", "text": "惠普完整版127_128",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_1530_printer.png", "program_url": "HP_LaserJet_M1530_MFP_Series_PCL6.exe",
"spc_url": "HP_LaserJet_M1530_MFP_Series_PCL6.spc", "text": "惠普打印机1530",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/hp_1530_printer.png", "program_url": "hp_M1530_MFP_full_Solution_15189.exe",
"spc_url": "hp_M1530_MFP_full_Solution_15189.spc", "text": "惠普完整版1530",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/sharp_3140_printer.png", "program_url": "Sharp_MX_3140NC.exe", "spc_url": "Sharp_MX_3140NC.spc",
"text": "夏普3140打印机", "needed_admin": True, "installation_word": "安装", "usedbclick_execute": False,
"scope": get_scope()},
{"img_url": "img/sharp_3148_printer.png", "program_url": "Sharp-MX-3148NC.exe", "spc_url": "Sharp-MX-3148NC.spc",
"text": "夏普打印机3148",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/sharp_4081DX_printer.png", "program_url": "sharp-4081DX.zip", "spc_url": "sharp-4081DX.spc",
"text": "夏普打印机4081D",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/ban_ma_printer.png", "program_url": "ban_ma_printer.exe", "spc_url": "ban_ma_printer.spc",
"text": "斑马打印机",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
{"img_url": "img/Ezscan_gl72r.png", "program_url": "GL7273DrvSetup.zip", "spc_url": "GL7273DrvSetup.spc",
"text": "译维GL72R",
"needed_admin": True, "installation_word": "安装", "usedbclick_execute": False, "scope": get_scope()},
]
# downloading 刚开始程序初始化时,表示此时未下载
downloading = 0
# print(list_softwares)
# 把 get_scope:False的移除掉
list_softwares = [software for software in list_softwares if software["scope"] == "1"]
# 创建并放置按钮
for i in range(len(list_softwares)):
button_number = i + 1 # 按钮编号从1开始
one_software = list_softwares[i]
needed_admin = one_software['needed_admin']
program_url = one_software['program_url']
spc_url = one_software['spc_url']
text = one_software['text']
installation_word = one_software['installation_word']
usedbclick_execute = one_software['usedbclick_execute']
# 确保替换为你的图片路径,且图片格式为PNG或GIF
# img = tk.PhotoImage(file=f"{current_dir}/{one_software['img_url']}")
img_url = one_software['img_url']
image_pre = img_url
image_pre = image_pre.split('/')[-1]
image_pre = image_pre.split('\\')[-1]
image_pre = image_pre.split('.')[0]
print(image_pre)
image = base64_to_image(image_pre)
# img = tk.PhotoImage(file=f"{one_software['img_url']}")
# 创建标签用来显示图像
label = tk.Label(child_frame, image=image)
label.image = image
# 使用 grid 布局,每行5个按钮
row = i // 8 # 计算行数
column = i % 8 # 计算列数
label.grid(row=row * 2, column=column, padx=5, pady=5)
button = tk.Button(child_frame, text=f"{one_software['text']}", command=lambda num=button_number,
needed_admin=needed_admin,
program_url=program_url,
installation_word=installation_word,
usedbclick_execute=usedbclick_execute,
spc_url=spc_url,
text=text: button_click(num,
needed_admin,
program_url,
spc_url,
text,
installation_word,
usedbclick_execute,
))
button.grid(row=row * 2 + 1, column=column, padx=5, pady=5) # 添加适当的间距
##button.grid(row=i//5, column=i%5, padx=5, pady=5)
# 允许 Canvas 在 Y 轴上滚动
parent_frame.update() # 确保我们有正确的尺寸信息
canvas.configure(scrollregion=canvas.bbox("all"))
# 启动Tkinter事件循环
root.mainloop()