This is the code. I’m compiling it to an exe with auto-py-to-exe.
JavaScript
x
27
27
1
from tkinter import *
2
import os
3
4
master = Tk()
5
master.title('Power Options')
6
master.geometry("300x100")
7
master.wm_iconbitmap("poweroptions.ico")
8
9
def fun():
10
os.system('cmd /k shutdown /s /f /t 0')
11
12
def fun2():
13
os.system('cmd /k shutdown /r /f /t 0')
14
15
def fun3():
16
os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
17
18
b1 = Button(master,text = " Shutdown ",command = fun,activeforeground = "red",activebackground = "pink",padx=10)
19
b2 = Button(master,text = " Restart ",command = fun2,activeforeground = "red",activebackground = "pink",padx=10)
20
b3 = Button(master,text = " Sleep ",command = fun3,activeforeground = "red",activebackground = "pink",padx=10)
21
22
b3.place(relx=0.5, rely=0.5, anchor=CENTER)
23
b1.place(relx=0.1, rely=0.5, anchor=W)
24
b2.place(relx=0.9, rely=0.5, anchor=E)
25
26
master.mainloop()
27
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.