[英]Fatal Error: Failed to execute "script name" | auto-py-to-exe
This is the code.这是代码。 I'm compiling it to an exe with auto-py-to-exe.我正在使用 auto-py-to-exe 将其编译为 exe。
from tkinter import *
import os
master = Tk()
master.title('Power Options')
master.geometry("300x100")
master.wm_iconbitmap("poweroptions.ico")
def fun():
os.system('cmd /k shutdown /s /f /t 0')
def fun2():
os.system('cmd /k shutdown /r /f /t 0')
def fun3():
os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
b1 = Button(master,text = " Shutdown ",command = fun,activeforeground = "red",activebackground = "pink",padx=10)
b2 = Button(master,text = " Restart ",command = fun2,activeforeground = "red",activebackground = "pink",padx=10)
b3 = Button(master,text = " Sleep ",command = fun3,activeforeground = "red",activebackground = "pink",padx=10)
b3.place(relx=0.5, rely=0.5, anchor=CENTER)
b1.place(relx=0.1, rely=0.5, anchor=W)
b2.place(relx=0.9, rely=0.5, anchor=E)
master.mainloop()
When I compile it, it gives me the error in the title when I run it.当我编译它时,它在我运行它时给了我标题中的错误。 The script runs fine when I run it as a python (.py) file.当我将它作为 python (.py) 文件运行时,该脚本运行良好。
Solved it.解决了。 Just needed to delete "master.wm_iconbitmap("poweroptions.ico")" because I was not using it.只需要删除“master.wm_iconbitmap("poweroptions.ico")”,因为我没有使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.