在本专栏中介绍了一些工具,这里相当于为它们编写了一个主菜单,方便你进行管理。
导入必要的库:
import sys
import tkinter
import os
定义一个函数,传入一个路径,运行对应目录下的工具:
def call(types):
f2 = open("path.txt", "r", encoding="UTF-8")
path = f2.readline()
f2.close()
os.system(command=f"start {path}\\{types}\\{types}.exe") # 极其关键的一行
sys.exit()
为主菜单编写ui:
def main():
global screen
screen = tkinter.Tk() # 窗口初始化
screen.title("凡尘的脚本") # 设置标题
screen.geometry("500x300+250+120") # 设置窗口大小与初始化位置
screen.iconbitmap("ironmouse.ico") # 设置窗口图标
screen.resizable(width=False, height=False) # 禁止改变窗口大小!!!!!!
# screen.bind("<Button-1>", click)
# screen.bind('<Motion>', move)
font1 = ("SimSun", 25) # 设置主要字体
tkinter.Canvas(screen, height=300, width=505, bg='grey').place(x=-5, y=0)
tkinter.Button(screen, text="键鼠精灵", font=font1, command=lambda: call(types="键鼠精灵"), bg='#777777',
activebackground='#777777').place(x=40, y=30)
tkinter.Button(screen, text="键盘音效", font=font1, command=lambda: call(types="键盘音效"), bg='#777777',
activebackground='#777777').place(x=40, y=200)
tkinter.Button(screen, text="壁纸更换", font=font1, command=lambda: call(types="壁纸更换"), bg='#777777',
activebackground='#777777').place(x=250, y=30)
tkinter.Button(screen, text="图片爬虫", font=font1, command=lambda: call(types="图片爬虫"), bg='#777777',
activebackground='#777777').place(x=250, y=115)
screen.mainloop()
最后运行main即可。