我用python tkinter做了个进度条程序,pyinstaller打包成exe后报错:
然后,按照网上的办法关了pycharm,改了打包命令,通通不行。
请问,有没有人知道该怎么办?
附:
我的源码:
from tkinter import Tk,Button
from tkinter.ttk import Progressbar
from os import remove
from sys import exit,argv
def turn():
global run
global button1
run=not run
if run:
button1["text"]="Stop"
button1["bg"]="red"
button1["fg"]="white"
else:
button1["text"]="Run"
button1["bg"]="green"
button1["fg"]="black"
def over():
global root
try:
root.destroy()
except:
remove(argv[0])
exit()
root=Tk()
ww=500
wh=50
w=root.winfo_screenwidth()
h=root.winfo_screenheight()
root.geometry(f"{ww}x{wh}+{w//2-ww//2}+{h//2-wh//2}")
root.overrideredirect(True)
root.wm_attributes('-topmost',1)
allL=10000
steps=2
progressbar=Progressbar(root)
progressbar["maximum"]=allL
progressbar["value"]=0
progressbar.pack(fill="both",expand=True,side="left")
run=False
button1=Button(root,text="Run",bg="green",fg="black",command=lambda :turn())
button1.pack(fill="both",expand=True,side="top")
button2=Button(root,text="Over",bg="red",fg="black",command=lambda :over())
button2.pack(fill="both",expand=True,side="bottom")
try:
while not run:
root.update()
while progressbar["value"]<=allL:
if run:
progressbar["value"]+=steps
root.update()
progressbar["value"]=allL
remove(argv[0])
root.destroy()
root.mainloop()
except:
remove(argv[0])
exit()
求答案,谢谢。