What I want is to make my computer sleep after about 10 seconds but I want it to have a message with a cancel button
this is what I tried:
this is my warning with tkinter:
from tkinter import *
import ctypes
def callback():
quit()
root = Tk()
root.geometry("400x268")
root.title("Alert")
root.configure(background='light blue')
label = Label(root, text="ALERT this device will go to sleep soon!", fg="red")
label.config(font=("Courier", 12))
label.configure(background='light blue')
quitButton = Button(root, text="do not sleep!", command=callback)
quitButton.pack()
quitButton.place(x=150, y=150)
label.pack()
root.mainloop()
I need it to count back until sleep (this command):
import time
import os
os.system("Powercfg -H OFF")
os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")
but if I press the cancel button it will stop and nothing will happen