小工具2.1&英文版1.0
这是一个小工具的新版本,删掉了登录和注册(因为那个实际上不需要)
然后还把它翻译成了英文
还加了一个打开文件的功能
2.1代码:
#导入 from tkinter import * import tkinter as tk import os from time import sleep import tkinter.ttk as ttk from tkinter.filedialog import askdirectory import webbrowser from threading import Thread import sys import time from random import randint, choice import tkinter.messagebox as msgbox from datetime import datetime from datetime import date from datetime import timedelta import random from tkinter import messagebox import tkinter as tk import random from time import sleep import random import tkinter import threading from ctypes import * from pathlib import Path import threading import tkinter as tk import tkinter.ttk as ttk import tkinter.filedialog as filebox import tkinter.messagebox as msgbox import time from random import randint import sys import threading from time import sleep import os import webbrowser try: from tkwebview2.tkwebview2 import WebView2 except: os.system('pip install tkwebview2 -i https://pypi.douban.com/simple/') #看不懂,也杂乱到无法写 def locate_pip(name=''): os.system("where pip") os.system("where pip3") print('==================================================') def install(name,arg1='',arg2=''): os.system(pip_path+" install "+name+' -i https://pypi.douban.com/simple') print('==================================================') def uninstall(name): if name=='pip': print('想什么呢?你准备卸载PyPI?') else: os.system(pip_path+" uninstall "+name) print('==================================================') def upgrade(name=''): os.system(python_path+" -m pip install --upgrade pip -i https://pypi.douban.com/simple") print('==================================================') def list_pkg(name=''): os.system(pip_path+" list") print('==================================================') def about(name=''): os.system(pip_path+" --version") print('==================================================') def start(func,p=''): #print(func) dprint('将向函数传入此类型的参数:'+str(type(p))) dprint('将向函数传入参数:'+p) #t=Thread(target=func,args=p) t=Thread(target=lambda:func(p)) t.start() def view(url): webbrowser.open(url) def showDebug(show_info=False): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi=False sdi_btn['text']='显示调试信息' else: sdi=True sdi_btn['text']='隐藏调试信息' else: if sdo: win.geometry('300x340') sdo_btn['text']='显示调试选项 v' egg_count=0 sdo=False else: win.geometry('300x425') sdo_btn['text']='隐藏调试选项 ^' sdo=True def dprint(msg): global sdi if sdi: print(msg) def init(): global py_path,pip_path,python_path try: dprint('正在读取配置信息') py_path_f=open("./py_path.cfg",'r',encoding='utf-8') py_path=py_path_f.read() dprint('根据配置信息,您的Python位于:'+py_path) py_path_f.close() pip_path=py_path+"/scripts/pip.exe" python_path=py_path+"/python.exe" dprint('读取完成') if py_path=='使用环境变量': dprint('使用环境变量') pip_path='pip' except Exception as e: dprint('读取设置失败:'+str(e)) py_path=askdirectory(title='请选择Python安装路径') py_path_f=open("./py_path.cfg",'w',encoding='utf-8') py_path_f.write(py_path) py_path_f.close() pip_path=py_path+"/scripts/pip.exe" def showDebug(show_info=False): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi=False sdi_btn['text']='显示调试信息' else: sdi=True sdi_btn['text']='隐藏调试信息' else: if sdo: win.geometry('300x340') sdo_btn['text']='显示调试选项 v' egg_count=0 python_path='python' #Easy PyPi的定义 def pypi(): global sdo,sdo_btn,sdi,egg_count sdo=False sdi=False if len(sys.argv)>=1 and '-debug' in sys.argv: sdi=True sdi=False if len(sys.argv)>=1 and '-debug' in sys.argv: sdi=True #兼容版不包含彩蛋 dprint('您传入了参数:'+str(sys.argv)) win=tk.Tk() win.title('Easy PyPI V1.3.0') win.geometry('300x340') win.resizable(0,0) win.update() init() name_enter=ttk.Entry(win) name_enter.pack(fill=tk.X) dprint('执行: '+pip_path+' install '+'(库名)'+' -i https://pypi.douban.com/simple') print('==================================================') #功能区 ttk.Button(win,text='安装',command=lambda:start(install,name_enter.get())).pack(fill=tk.X) ttk.Button(win,text='卸载',command=lambda:start(uninstall,name_enter.get())).pack(fill=tk.X) ttk.Button(win,text='关于此库',command=lambda:view("https://pypi.org/project/"+name_enter.get()+"/")).pack(fill=tk.X) ttk.Button(win,text='列出所有已经安装的库',command=lambda:start(list_pkg)).pack(fill=tk.X) ttk.Button(win,text='更新PIP',command=lambda:start(upgrade)).pack(fill=tk.X) ttk.Button(win,text='关于PIP',command=lambda:start(about)).pack(fill=tk.X) ttk.Button(win,text='查看环境变量中有关PIP路径的配置',command=lambda:start(locate_pip)).pack(fill=tk.X) sdo_btn=ttk.Button(win,text='显示调试选项 v',command=showDebug) sdo_btn.pack(fill=tk.X) #介绍区被删去,因为它被CHM所替代 tk.Button(win,text='2022 By 人工智障',bg='lightgrey',bd=0,command=lambda:view("https://www.cnblogs.com/totowang")).pack(fill=tk.X) tk.Button(win,text='问题反馈',bg='lightgrey',bd=0,command=lambda:view("https://support.qq.com/products/384388?")).pack(fill=tk.X) tk.Button(win,text='帮助',bg='lightgrey',bd=0,command=lambda:view("http://rgzz.great-site.net/soft/ezpip/WebHelp/")).pack(fill=tk.X) tk.Button(win,text='开源许可证',bg='lightgrey',bd=0,command=lambda:view("https://www.mozilla.org/en-US/MPL/1.1/")).pack(fill=tk.X) #调试选项 ttk.Button(win,text='显示输入的内容',command=lambda:print(name_enter.get()+'\n'+'==================================================')).pack(fill=tk.X) ttk.Button(win,text='使用内建网页查看器打开输入的网址',command=lambda:view(name_enter.get())).pack(fill=tk.X) sdi_btn=ttk.Button(win,text='显示调试信息',command=lambda:showDebug(show_info=True)) sdi_btn.pack(fill=tk.X) win.mainloop() #你好的定义 def func(): a=input('使用者姓名:') if a == 'fuckey house': print('你好我爱你快乐屋') elif a == 'sb': print('请问你是马睿智吗?') print('是的话那没事了') time.sleep(1) print('不是的话请不要骂人哦') else: print(a,'你好') #选择到底开不开彩蛋 def bu(): win=tk.Tk() win.title('选择') ttk.Button(win,text='打开',command=egg).pack(fill=tk.X) ttk.Button(win,text='不开',command=lambda:win.destroy()).pack(fill=tk.X) #《彩蛋》 def egg(): #webbrowser.open("https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1") eggwin=tk.Tk() eggwin.title('你发现了彩蛋!') countdown_label=tk.Label(eggwin,text='你发现了彩蛋!',font=('微软雅黑','50')) countdown_label.pack() eggwin.update() sleep(2) countdown=3 for i in range(0,3): countdown_label['text']='惊喜揭晓!'+str(countdown) eggwin.update() countdown-=1 sleep(1) countdown_label.destroy() frame=WebView2(eggwin,960,540) frame.load_url("https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1&t=0.0001") frame.pack(fill=tk.BOTH,expand=True) eggwin.title('没错,你被骗了') eggwin.mainloop() #黄金一百秒的定义 def shutdown(): os.system('shutdown -s -t 100') msgbox.showwarning('嘿嘿!','请珍惜你的黄金100秒!') #也不知道是什么,从哪里来的 def daa(): print('给你一个惩罚') hero.hp -= 10000 print('再见。。。') #实名认证 class IdentityCard: def __init__( self ): self.__Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] self.__Ti = ['1', '0', 'x', '9', '8', '7', '6', '5', '4', '3', '2'] def check( self, code ): if (len(code) != 17): print("必须为17位的字符") return False return True def calculate( self, code ): sum = 0 for i in range(17): sum += int(code[i])*self.__Wi[i] return self.__Ti[sum%11] #小游戏 def game(): print('2022 By 假_人工智障') time.sleep(3) print('====================') print('实名认证') print('--------------------') while True: name=str(input('请输入真实姓名:')) i=input('请输入您的身份证号:') me=i ic = IdentityCard() year=int(me[6:10]) nowyear=datetime.now().year print('用户生于'+str(year)+'年') if len(me) != 18 or len(name)<2 or len(name)>18: print("\033[0;31;40m实名认证失败!请检查姓名和身份证号!\033[0m") print('====================') elif ic.calculate(i[0:17:])!=i[17:18:]: print("\033[0;31;40m嗯?\033[0m") time.sleep(0.3) print("\033[0;31;40m嗯?不对……你想拿假身份证哄我是吧!?\033[0m") print('====================') elif year-nowyear<18: print('检测到您是未成年人') if datetime.weekday(datetime.now())!= 5 and datetime.weekday(datetime.now())!=6: print('\033[0;31;40m非常抱歉,但是未成年人只能在周末游玩。今天是星期'+str(datetime.weekday(datetime.now()))+'\033[0m') time.sleep(5) exit() print('为保护青少年身心健康,我们仅允许未成年人每次游玩10分钟。') break else: break print('====================') print('''健康游戏忠告: 抵制不良游戏,拒绝盗版游戏。 注意自我保护,谨防受骗上当。 适度游戏益脑,沉迷游戏伤身。 合理安排时间,享受健康生活。''') time.sleep(5) print('====================') b=input('请输入玩家姓名:') c=input('请输入恶龙姓名:') class Hero: # 角色 def __init__(self, name): self.name = name # 名字 self.hp = 1000 # 生命值 self.atk = 300 # 攻击力 self.dfs = 250 # 防御力 self.medicine = 5 # 药物 def attack(self, player): # 攻击, player是被攻击的对象 d = self.atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp -= d # 对方血量减少 print("%s暴打了%s ,造成了%d伤害" % (self.name, player.name, d)) def treatment(self): # 治疗 if self.medicine > 0: self.hp += 500 self.medicine -= 1 print("治疗成功!") else: print("药水不足!") def persuade(self): # 劝降 n = randint(1, 100) # 生成一个随机数 if n <= 10: # 1/1的概率成功 return True else: return False class Dragon: # 恶龙 def __init__(self, name): self.name = name # 名字 self.hp = randint(500, 1500) # 生命值 self.atk = randint(300, 500) # 攻击力 self.dfs = randint(25, 75) # 防御力 def attack(self, player): # 攻击, player是被攻击的对象 d = self.atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp -= d # 对方血量减少 print("%s攻击了%s ,造成了%d伤害" % (self.name, player.name, d)) print("小女孩: 救命啊") time.sleep(1) print(c,":你喊破喉咙也不会有人来救你的") time.sleep(1) print("这时一个身影出现在附近...") time.sleep(1) # 实例化对象,可以自定义名字 hero = Hero(b) dragon = Dragon(c) # 游戏过程 while True: print("-------------------------------------") print("英雄血量:", hero.hp) print('英雄攻击:',hero.atk) print('英雄防御:',hero.dfs) print("药物数量: ", hero.medicine) # 勇者回合 key = input("请输操作 1.攻击 2.治疗 3.劝降:") if key == "1": # 攻击 hero.attack(dragon) time.sleep(1) elif key == "2": # 治疗 hero.treatment() time.sleep(1) elif key == "3": # 劝降 print("%s: 恶龙,我劝你善良!" % hero.name) time.sleep(1) if hero.persuade(): print("%s: 你的真诚打动了,我决定做一个好龙。" % dragon.name) print("%s放了小女孩。" % dragon.name ) print("游戏结束!") break else: print("%s: 想都别想,除非战胜我!" % dragon.name) elif key == "123": print('恭喜你发现彩蛋!') time.sleep(1) dragon.hp -= 10000 print("%s被打败了。" % dragon.name) print("%s: 恶龙,我劝你善良!" % hero.name) time.sleep(1) if hero.persuade(): print("%s: 你的真诚打动了,我决定做一个好龙。" % dragon.name) print("%s放了小女孩。" % dragon.name ) print("游戏结束!") break else: print("%s: 想都别想,除非战胜我!" % dragon.name) elif key == "123": print('恭喜你发现彩蛋!') time.sleep(1) dragon.hp -= 10000 print("%s被打败了。" % dragon.name) print("小女孩得救了。") print("游戏结束!") break time.sleep(1) elif key == "彩蛋": print('恭喜你发现彩蛋!') egg() elif key == '大招': print('大招?你在想什么?被动吗?') time.sleep(1) print('不过真的有大招哦') d = randint(900,1000) print(b,"使用了大招,对",c,'造成了',d,'伤害。') dragon.hp -= d elif key == '被动技能': print('Emmm。。。额,被动没啥用。。。') print('狂暴?') hero.hp += 5000 hero.atk += 2500 hero.dfs += 2500 elif key =='1技能': print('你又在干什么???') print('没有吧?') time.sleep(1) print('开玩笑的') dragon.hp -= 200 elif key =='2技能': print('你又在异想天开吧') print('王者荣耀玩多了') print('嘿嘿嘿') time.sleep(1) hero.hp += 250 elif key =='召唤师技能': print('你一看就是王者荣耀玩多了') print('Emmm......你在干什么???') print('我来帮你戒网瘾吧~') print('嘿嘿嘿') hero.hp -= 100000000000000 print('去死吧您嘞') elif key == '114514': print('不要玩梗!!!') print('你在搞什么快乐星球?') print('你值得拥有996') print('另一个梗嗷') egg() else: # 输入信息有误,跳到循环开始 print("嗯……所以你在干什么?") continue # 恶龙回合 dragon.attack(hero) # 恶龙攻击英雄 time.sleep(1) # 游戏结束条件 if dragon.hp <= 0: # 恶龙血量为0 print("%s被打败了。" % dragon.name) print("小女孩得救了。") print("游戏结束!") break if hero.hp <= 0: # 英雄血量为0 print("Emmm。。。%s没了" % hero.name) print("出师未捷身先死 长使英雄泪满襟") print("游戏结束!") break #打开后读取文件的界面 def cho(): global file file = filebox.askopenfilename(title='请选择路径') print('你选择的文件是', file) tk.messagebox.showinfo('提示', '你选择了文件') f = open(file, 'r') en = tk.Tk() ttk.Button(en, text='读取文件', command=readfile).pack(fill=tk.X) ttk.Button(en, text='运行文件', command=run).pack(fill=tk.X) ttk.Button(en, text='退出程序(小工具也会被退出)', command=lambda: exit()).pack(fill=tk.X) #读取文件 def readfile(): global file f = open(file, 'r', encoding='utf-8') print() print('===============================================') print(f.read()) #运行文件 def run(): global file os.system(file) #选择文件 def op(): op = tk.Tk() op.wm_attributes ('-topmost',1) ttk.Button(op, text='选择文件', command=cho).pack(fill=tk.X) op.mainloop() #一个无聊的卡爆临时内存的东西 def emmm(): s=0 txt='#####' while True: print('卡爆你电脑临时内存,嘿嘿嘿,加油把它关掉吧~') txt+=txt s += 1 if s == 10: wanttoquit=input('你想反悔吗?(Y/n) ') if wanttoquit.lower()=='y': print('你真觉得我会让你反悔?') if wanttoquit.lower()=='n': print('不知好歹是吧?') if wanttoquit=='我真要反悔啊!!!': pwd=input('请输入反悔密码: ') if pwd=='114514': print('行吧,暂且放过你一次') break else: print('去死吧您嘞') else: print('好好回答我它不香吗?算了,我默认你不想') #锁屏 def lock(): setpwd=input('请输入您的锁屏密码') def unlock(pwd,event=''): global msg if pwd==setpwd: win.destroy() elif pwd=='': msg['text']='请先输入密码!' else: msg['text']='抱歉,密码错误,无法解锁!' win=tk.Tk() win.wm_attributes('-topmost', 1) win.configure(background='#000000') win.attributes('-fullscreen',True) tk.Label(win,text='计算机已锁定',font=('微软雅黑',50),anchor='w',bg='#000000',fg='#FFFFFF').pack(fill=tk.X,padx=120,pady=30) enter=tk.Entry(win,show='●',font=('微软雅黑',25),bd=0,bg='#333333',fg='#FFFFFF') enter.pack(padx=100,fill=tk.X,pady=25) tk.Button(win,text='解锁',command=lambda:unlock(enter.get()),bg='#333333',fg='#FFFFFF',bd=0,width=10,font=('微软雅黑',15)).pack(padx=100,pady=25) msg=tk.Label(win,text='',font=('微软雅黑',15),bg='#000000',fg='#900000') msg.pack(fill=tk.X) win.mainloop() #打开网站界面 def web(): a = Tk() a.title('打开网站') a.wm_attributes('-topmost',1) l_user = Label(a,text='网址:') l_user.pack(fill=tk.X) e_user =Entry(a) e_user.pack(fill=tk.X) ttk.Button(a,text='打开百度',command=lambda:webbrowser.open("https://www.baidu.com/")).pack(fill=tk.X) ttk.Button(a,text='打开Edge',command=lambda:webbrowser.open("https://cn.bing.com/")).pack(fill=tk.X) ttk.Button(a,text='打开B站',command=lambda:webbrowser.open("https://www.bilibili.com/")).pack(fill=tk.X) ttk.Button(a,text='打开VCG',command=lambda:webbrowser.open('https://www.vcg.com/')).pack(fill=tk.X) ttk.Button(a,text='打开博客园',command=lambda:webbrowser.open('https://www.cnblogs.com/')).pack(fill=tk.X) ttk.Button(a,text='打开C语言中文网',command=lambda:webbrowser.open('http://c.biancheng.net/')).pack(fill=tk.X) ttk.Button(a,text='打开维基百科',command=lambda:webbrowser.open('chinois.jinzhao.wiki')).pack(fill=tk.X) ttk.Button(a,text='打开输入的网址',command=lambda:view(e_user.get())).pack(fill=tk.X) #打开一些系统文件 def c(): c = tk.Tk() c.wm_attributes ('-topmost',1) c.title('打开工具') ttk.Button(c,text='打开注册表编辑器',command=lambda:os.popen("start regedit")).pack(fill=tk.X) ttk.Button(c,text='打开计算器',command=lambda:os.popen("start calc")).pack(fill=tk.X) ttk.Button(c,text='打开命令提示符',command=lambda:os.popen("start cmd")).pack(fill=tk.X) ttk.Button(c,text='打开任务管理器',command=lambda:os.popen("start taskmgr")).pack(fill=tk.X) ttk.Button(c,text='打开字符映射表',command=lambda:os.popen('start charmap')).pack(fill=tk.X) ttk.Button(c,text='打开计算机管理',command=lambda:os.popen('start compmgmt.msc')).pack(fill=tk.X) ttk.Button(c,text='打开控制面板',command=lambda:os.popen('start control')).pack(fill=tk.X) ttk.Button(c,text='打开文件资源管理器',command=lambda:os.popen('start explorer.exe')).pack(fill=tk.X) ttk.Button(c,text='打开文件',command=op).pack(fill=tk.X) ttk.Button(c,text='打开Easy PyPI',command=pypi).pack(fill=tk.X) #关机项目 def shutup(): shut = Tk() shut.wm_attributes ('-topmost',1) shut.title('关机项') ttk.Button(shut,text='黄金100秒',command=shutdown).pack(fill=tk.X) ttk.Button(shut,text='马上关机',command=lambda:os.system('shutdown -s -t 0')).pack(fill=tk.X) #小工具输入框版功能区 def text(): a = Tk() a.title("小工具输入框版") a.wm_attributes ('-topmost',1) def reg(): User = e_user.get() len_user = len(User) if User=='命令提示符': os.popen('start cmd') elif User=='任务管理器': os.popen("start taskmgr") elif User=='计算器': os.popen('start calc') elif User=='作者博客': webbrowser.open('https://www.cnblogs.com/fakeai') elif User=='小游戏': game() elif User=='Never Gonna Give You Up': egg() else: l_user['text']='无法运行呢亲' e_user.delete(0,len_user) l_user =Label(a,text='命令:') l_user.grid(row=0,sticky=W) e_user =Entry(a) e_user.grid(row=0,column=1,sticky=E) b_login = Button(a,text='运行命令',command=reg) b_login.grid(row=2,column=1,sticky=E) l_user['text']='2022 By 假_人工智障' a.mainloop() #按钮版小工具功能区 def work(): root=tk.Tk() root.wm_attributes ('-topmost',1) root.title('我的百宝箱') tk.Listbox(root) ttk.Button(root,text='你好',command=func).pack(fill=tk.X) ttk.Button(root,text='小游戏',command=game).pack(fill=tk.X) ttk.Button(root,text='打开工具',command=c).pack(fill = tk.X) ttk.Button(root,text='打开网站',command=web).pack(fill = tk.X) ttk.Button(root,text='关机项',command=shutup).pack(fill=X) ttk.Button(root,text='密码锁屏',command=lock).pack(fill=tk.X) ttk.Button(root,text='EMMM。。。加载中?',command=emmm).pack(fill=tk.X) ttk.Button(root,text='嘿嘿嘿',command=bu).pack(fill=tk.X) tk.Button(root,text='2022 By 假_人工智障',bg='lightgrey',bd=0,command=lambda:webbrowser.open('https://www.cnblogs.com/fakeai')).pack(fill=tk.X) root.mainloop() #多线程的都开 def more(): butt = threading.Thread(target=work) label = threading.Thread(target=text) butt.start() label.start() #选择到底开按钮版还是输入框版(也不排除有人想都开) def choose(event=''): b=tk.Tk() b.wm_attributes ('-topmost',1) ttk.Button(b,text='按钮版',command=work).pack(fill=tk.X) ttk.Button(b,text='输入框版',command=text).pack(fill=tk.X) ttk.Button(b,text='都开',command=more).pack(fill=tk.X) b.mainloop() #欢迎使用 hi=''' 欢迎使用小工具2.1版本! 本程序由假_人工智障开发. 作者的博客:www.cnblogs.com/faekai 作者的邮箱:lpj20090202@outlook.com 请确保安装了python的tkwebview2 ''' #输出欢迎使用的内容 print(hi) #选择 choose()
英文版代码:
#import from tkinter import * import tkinter as tk import os from time import sleep import tkinter.ttk as ttk from tkinter.filedialog import askdirectory import webbrowser from threading import Thread import sys try: from tkwebview2.tkwebview2 import WebView2 except: os.system('pip install tkwebview2 -i https://pypi.douban.com/simple/') import time from random import randint, choice import tkinter.messagebox as msgbox from datetime import datetime from datetime import date from datetime import timedelta import random from tkinter import messagebox import tkinter as tk import random from time import sleep import random import tkinter import threading from ctypes import * from pathlib import Path import threading #NOPE def locate_pip(name=''): os.system("where pip") os.system("where pip3") print('==================================================') def install(name,arg1='',arg2=''): os.system(pip_path+" install "+name+' -i https://pypi.douban.com/simple') print('==================================================') def uninstall(name): if name=='pip': print('Thoughts? Are you ready to uninstall PyPI?') else: os.system(pip_path+" uninstall "+name) print('==================================================') def upgrade(name=''): os.system(python_path+" -m pip install --upgrade pip -i https://pypi.douban.com/simple") print('==================================================') def list_pkg(name=''): os.system(pip_path+" list") print('==================================================') def about(name=''): os.system(pip_path+" --version") print('==================================================') def start(func,p=''): #print(func) dprint('Parameters of this type are passed to the function: '+str(type(p))) dprint('Parameters are passed to the function: '+p) #t=Thread(target=func,args=p) t=Thread(target=lambda:func(p)) t.start() def view(url): webbrowser.open(url) def showDebug(show_info=False): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi=False sdi_btn['text']='Show debugging information' else: sdi=True sdi_btn['text']='Hide debugging information' else: if sdo: win.geometry('300x340') sdo_btn['text']='Show debugging information v' egg_count=0 sdo=False else: win.geometry('300x425') sdo_btn['text']='Hide debugging information ^' sdo=True def dprint(msg): global sdi if sdi: print(msg) def init(): global py_path,pip_path,python_path try: dprint('Reading configuration information') py_path_f=open("./py_path.cfg",'r',encoding='utf-8') py_path=py_path_f.read() dprint('Depending on the configuration information, your Python is located: '+py_path) py_path_f.close() pip_path=py_path+"/scripts/pip.exe" python_path=py_path+"/python.exe" dprint('Read complete') if py_path=='Use environment variables': dprint('Use environment variables') pip_path='pip' except Exception as e: dprint('Failed to read settings: '+str(e)) py_path=askdirectory(title='Please select the Python installation path') py_path_f=open("./py_path.cfg",'w',encoding='utf-8') py_path_f.write(py_path) py_path_f.close() pip_path=py_path+"/scripts/pip.exe" def showDebug(show_info=False): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi=False sdi_btn['text']='Show debugging information' else: sdi=True sdi_btn['text']='Hide debugging information' else: if sdo: win.geometry('300x340') sdo_btn['text']='Show debugging information' egg_count=0 python_path='python' #def of Easy PyPi def pypi(): global sdo,sdo_btn,sdi,egg_count sdo=False sdi=False if len(sys.argv)>=1 and '-debug' in sys.argv: sdi=True sdi=False if len(sys.argv)>=1 and '-debug' in sys.argv: sdi=True #The compatibility version does not contain Easter eggs dprint('You pass in the parameters: '+str(sys.argv)) win=tk.Tk() win.title('Easy PyPI V1.3.0') win.geometry('300x340') win.resizable(0,0) win.update() init() name_enter=ttk.Entry(win) name_enter.pack(fill=tk.X) dprint('execute: '+pip_path+' install '+'(Library name)'+' -i https://pypi.douban.com/simple') print('==================================================') #功能区 ttk.Button(win,text='insatll',command=lambda:start(install,name_enter.get())).pack(fill=tk.X) ttk.Button(win,text='uninstall',command=lambda:start(uninstall,name_enter.get())).pack(fill=tk.X) ttk.Button(win,text='About this library',command=lambda:view("https://pypi.org/project/"+name_enter.get()+"/")).pack(fill=tk.X) ttk.Button(win,text='Lists all installed libraries',command=lambda:start(list_pkg)).pack(fill=tk.X) ttk.Button(win,text='Update pip',command=lambda:start(upgrade)).pack(fill=tk.X) ttk.Button(win,text='About PIP',command=lambda:start(about)).pack(fill=tk.X) ttk.Button(win,text='Review the configuration of the PIP path in the environment variables',command=lambda:start(locate_pip)).pack(fill=tk.X) sdo_btn=ttk.Button(win,text='Displays debug option v',command=showDebug) sdo_btn.pack(fill=tk.X) #介绍区被删去,因为它被CHM所替代 tk.Button(win,text='2022 By rgzz_666',bg='lightgrey',bd=0,command=lambda:view("https://www.cnblogs.com/totowang")).pack(fill=tk.X) tk.Button(win,text='Feedback on the problem',bg='lightgrey',bd=0,command=lambda:view("https://support.qq.com/products/384388?")).pack(fill=tk.X) tk.Button(win,text='Help',bg='lightgrey',bd=0,command=lambda:view("http://rgzz.great-site.net/soft/ezpip/WebHelp/")).pack(fill=tk.X) tk.Button(win,text='Open source license',bg='lightgrey',bd=0,command=lambda:view("https://www.mozilla.org/en-US/MPL/1.1/")).pack(fill=tk.X) #调试选项 ttk.Button(win,text='Displays the input',command=lambda:print(name_enter.get()+'\n'+'==================================================')).pack(fill=tk.X) ttk.Button(win,text='Use the built-in web viewer to open the entered URL',command=lambda:view(name_enter.get())).pack(fill=tk.X) sdi_btn=ttk.Button(win,text='Displays debugging information',command=lambda:showDebug(show_info=True)) sdi_btn.pack(fill=tk.X) win.mainloop() #选择到底开不开彩蛋 def bu(): win=tk.Tk() win.title('choose') ttk.Button(win,text='Open',command=egg).pack(fill=tk.X) ttk.Button(win,text='Nope',command=lambda:win.destroy()).pack(fill=tk.X) #《彩蛋》 def egg(): #webbrowser.open("https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1") eggwin=tk.Tk() eggwin.title('You find Easter eggs!') countdown_label=tk.Label(eggwin,text='You find Easter eggs!',font=('微软雅黑','50')) countdown_label.pack() eggwin.update() sleep(2) countdown=3 for i in range(0,3): countdown_label['text']='Surprise revealed!'+str(countdown) eggwin.update() countdown-=1 sleep(1) countdown_label.destroy() frame=WebView2(eggwin,960,540) frame.load_url("https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1&t=0.0001") frame.pack(fill=tk.BOTH,expand=True) eggwin.title('That is right, you’ve been lied to') eggwin.mainloop() #黄金一百秒的定义 def shutdown(): os.system('shutdown -s -t 100') msgbox.showwarning('Hey hey!','Please cherish your golden 100 seconds!') #小游戏 def game(): print('2022 By rgzz_999') time.sleep(3) b=input('Please enter the player’s name:') c=input('Please enter the dragon name:') class Hero: # 角色 def __init__(self, name): self.name = name # 名字 self.hp = 1000 # 生命值 self.atk = 300 # 攻击力 self.dfs = 250 # 防御力 self.medicine = 5 # 药物 def attack(self, player): # 攻击, player是被攻击的对象 d = self.atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp -= d # 对方血量减少 print("%sViolently beaten%s ,caused%dharm" % (self.name, player.name, d)) def treatment(self): # 治疗 if self.medicine > 0: self.hp += 500 self.medicine -= 1 print("Treatment successful!") else: print("Insufficient potion!") def persuade(self): # 劝降 n = randint(1, 100) # 生成一个随机数 if n <= 10: # 1/1的概率成功 return True else: return False class Dragon: # 恶龙 def __init__(self, name): self.name = name # 名字 self.hp = randint(500, 1500) # 生命值 self.atk = randint(300, 500) # 攻击力 self.dfs = randint(25, 75) # 防御力 def attack(self, player): # 攻击, player是被攻击的对象 d = self.atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp -= d # 对方血量减少 print("%sattacked%s ,caused%dharm" % (self.name, player.name, d)) # 实例化对象,可以自定义名字 hero = Hero(b) dragon = Dragon(c) # 游戏过程 while True: print("-------------------------------------") print("Hero hp:", hero.hp) print('Hero atk:',hero.atk) print('Hero dfs:',hero.dfs) print("Number of drugs: ", hero.medicine) # 勇者回合 key = input("Please enter the operation 1.Attack 2.Treatment 3.Dissuade:") if key == "1": # 攻击 hero.attack(dragon) time.sleep(1) elif key == "2": # 治疗 hero.treatment() time.sleep(1) elif key == "3": # 劝降 print("%s: Dragon, I advise you to be kind!" % hero.name) time.sleep(1) if hero.persuade(): print("%s: Your sincerity was impressed, and I decided to be a good dragon." % dragon.name) print("%sReleased the little girl" % dragon.name ) print("Game over!") break else: print("%s: Don't even think about it, unless you beat me!" % dragon.name) else: # 输入信息有误,跳到循环开始 print("Well...... So what are you doing?") continue # 恶龙回合 dragon.attack(hero) # 恶龙攻击英雄 time.sleep(1) # 游戏结束条件 if dragon.hp <= 0: # 恶龙血量为0 print("%sDefeated。" % dragon.name) print("The little girl was saved.") print("Game over!") break if hero.hp <= 0: # 英雄血量为0 print("Emmm。。。%shad gone" % hero.name) print("Death before the master succeeded In the long run, the hero burst into tears") print("Game over!") break #锁屏 def lock(): setpwd=input('Please enter your lock screen password: ') def unlock(pwd,event=''): global msg if pwd==setpwd: win.destroy() elif pwd=='': msg['text']='Please enter your password first!' else: msg['text']='Sorry, wrong password, can not unlock!' win=tk.Tk() win.configure(background='#000000') win.attributes('-fullscreen',True) tk.Label(win,text='The computer has been locked',font=('微软雅黑',50),anchor='w',bg='#000000',fg='#FFFFFF').pack(fill=tk.X,padx=120,pady=30) enter=tk.Entry(win,show='●',font=('微软雅黑',25),bd=0,bg='#333333',fg='#FFFFFF') enter.pack(padx=100,fill=tk.X,pady=25) tk.Button(win,text='Unlock',command=lambda:unlock(enter.get()),bg='#333333',fg='#FFFFFF',bd=0,width=10,font=('微软雅黑',15)).pack(padx=100,pady=25) msg=tk.Label(win,text='',font=('微软雅黑',15),bg='#000000',fg='#900000') msg.pack(fill=tk.X) win.mainloop() def web(): a = Tk() a.title('Open website') a.wm_attributes('-topmost',1) l_user = Label(a,text='website:') l_user.pack(fill=tk.X) e_user =Entry(a) e_user.pack(fill=tk.X) ttk.Button(a,text='Open baidu',command=lambda:webbrowser.open("https://www.baidu.com/")).pack(fill=tk.X) ttk.Button(a,text='Open Edge',command=lambda:webbrowser.open("https://cn.bing.com/")).pack(fill=tk.X) ttk.Button(a,text='Open Bilibili',command=lambda:webbrowser.open("https://www.bilibili.com/")).pack(fill=tk.X) ttk.Button(a,text='Open VCG',command=lambda:webbrowser.open('https://www.vcg.com/')).pack(fill=tk.X) ttk.Button(a,text='Open blogs',command=lambda:webbrowser.open('https://www.cnblogs.com/')).pack(fill=tk.X) ttk.Button(a,text='Open C.biancehng',command=lambda:webbrowser.open('http://c.biancheng.net/')).pack(fill=tk.X) ttk.Button(a,text='Open Enter website',command=lambda:view(e_user.get())).pack(fill=tk.X) #打开一些系统文件 def c(): c = tk.Tk() c.wm_attributes ('-topmost',1) c.title('打开工具') ttk.Button(c,text='Open Registry Editor',command=lambda:os.popen("start regedit")).pack(fill=tk.X) ttk.Button(c,text='Open calculator',command=lambda:os.popen("start calc")).pack(fill=tk.X) ttk.Button(c,text='Open cmd',command=lambda:os.popen("start cmd")).pack(fill=tk.X) ttk.Button(c,text='Open Task Manager',command=lambda:os.popen("start taskmgr")).pack(fill=tk.X) ttk.Button(c,text='Open Charger',command=lambda:os.popen('start charmap')).pack(fill=tk.X) ttk.Button(c,text='Open compmgmt',command=lambda:os.popen('start compmgmt.msc')).pack(fill=tk.X) ttk.Button(c,text='Open control',command=lambda:os.popen('start control')).pack(fill=tk.X) ttk.Button(c,text='Open explorer',command=lambda:os.popen('start explorer.exe')).pack(fill=tk.X) ttk.Button(c,text='Open Easy PyPI',command=pypi).pack(fill=tk.X) #关机项目 def shutup(): shut = Tk() shut.wm_attributes ('-topmost',1) shut.title('Shut down the item') ttk.Button(shut,text='Gold 100 seconds',command=shutdown).pack(fill=tk.X) ttk.Button(shut,text='Shut down immediately',command=lambda:os.system('shutdown -s -t 0')).pack(fill=tk.X) #小工具输入框版功能区 def text(): a = Tk() a.title("Gadget input box version") a.wm_attributes ('-topmost',1) def reg(): User = e_user.get() len_user = len(User) if User=='cmd': os.popen('start cmd') elif User=='Task Manager': os.popen("start taskmgr") elif User=='calculator': os.popen('start calc') elif User=='Author Blog': webbrowser.open('https://www.cnblogs.com/fakeai') elif User=='Mini-games': game() elif User=='Never Gonna Give You Up': egg() else: l_user['text']='Can not run it pro' e_user.delete(0,len_user) l_user =Label(a,text='command:') l_user.grid(row=0,sticky=W) e_user =Entry(a) e_user.grid(row=0,column=1,sticky=E) b_login = Button(a,text='Run the command',command=reg) b_login.grid(row=2,column=1,sticky=E) l_user['text']='2022 By rgzz_999' a.mainloop() #Button version tool def work(): root=tk.Tk() root.wm_attributes ('-topmost',1) root.title('My treasure chest') tk.Listbox(root) ttk.Button(root,text='Mini game',command=game).pack(fill=tk.X) ttk.Button(root,text='Open the tool',command=c).pack(fill = tk.X) ttk.Button(root,text='Open the website',command=web).pack(fill = tk.X) ttk.Button(root,text='Shut down the item',command=shutup).pack(fill=X) ttk.Button(root,text='Password lock screen',command=lock).pack(fill=tk.X) ttk.Button(root,text='Hey hey hey',command=bu).pack(fill=tk.X) tk.Button(root,text='2022 By rgzz_999',bg='lightgrey',bd=0,command=lambda:webbrowser.open('https://www.cnblogs.com/fakeai')).pack(fill=tk.X) root.mainloop() #All on def more(): butt = threading.Thread(target=work) label = threading.Thread(target=text) butt.start() label.start() #Choose whether to open the button version or the input box version (it is not excluded that some people want to open both) def choose(event=''): b=tk.Tk() b.wm_attributes ('-topmost',1) ttk.Button(b,text='Button version',command=work).pack(fill=tk.X) ttk.Button(b,text='Enter the box version',command=text).pack(fill=tk.X) ttk.Button(b,text='All on',command=more).pack(fill=tk.X) b.mainloop() #welcome hi=''' Welcome to Gadgets version 2.1! This program was developed by rgzz_999. Author's blog: www.cnblogs.com/faekai Author's email address: lpj20090202@outlook.com Make sure you have Python's tkwebview2 installed ''' #print welcome print(hi) #choose choose()
就没什么啦~
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下