Skip to content
Advertisement

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.

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.

Advertisement

Answer

Solved it. Just needed to delete “master.wm_iconbitmap(“poweroptions.ico”)” because I was not using it.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement