I'm trying to shut down the computer when the yes button of messagebox is clicked, but my code doesn't work somehow, and I don't know where is the problem
import tkinter as tk
from tkinter import messagebox
import os
res = messagebox.askquestion("Prezentácia bez názvu.pptx", "Failed to load. Do you wish to continue? ")
def shutdown():
return os.system("shutdown /s /t 1")
def askMe():
if res == 'yes':
command=shutdown
if res == 'no':
command=shutdown
you don`t need to use return in shutdown function, just remove the return keyword and in askMe function you can simply call shutdown function. In the last you have to call askMe function.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments