In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge about "Python how to make the computer shut down at the specified time". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
First look at the renderings
code is as follows
from tkinter import messagebox #messagepop import os #Used to execute cmd command import string #StringVar to use String Hook def text(): #Determine whether it is a number and process hours into seconds i=time.get() #Get string hook value try: wrong arrest Determine whether it is a number i=str(int(float(i)*60*60)) except ValueError: messagebox.showwarning(title="Input error",message="Please enter a number! ") #Warning message pop-up else: result=shutdown(i) def shutdown(i=False): #Execute cmd statement to set timed shutdown if i==False: result=os.system("shutdown -a") if result: messagebox.showwarning(title="Error",message="Currently no timing shutdown task") return 0 else: result=os.system("shutdown -s -t "+i) if result: result=os.system("shutdown -a") if not result: result=os.system("shutdown -s -t "+i) if not result: messagebox.showinfo(title="Status message",message="Success! ") else: messagebox.showerror(title="Error",message="Failure for unknown reason") soft=Tk()soft.title=()soft.geometry('155x90+885+465') #Initialize window size information soft.resizable(0, 0) #Setting window size cannot be changed text1=Label(soft,text="How many hours do you need to shut down? ",compound="center").grid(row=0,column=0,columnspan=2,padx=0,pady=0) #text time=StringVar() #declaration string hook time.set("1") #Set initial values text2=Entry(soft,textvariable=time).grid(row=1,column=0,columnspan=2,padx=5,pady=0) #Set Text Box grid button1=Button(soft,text="Cancel Task",command=shutdown).grid(row=2,column=0,padx=5,pady=10)button2=Button(soft,text="Set Task",command=text).grid(row=2,column=1,padx=5,pady=10)soft.mainloop() #Run
If you want to cancel, click Cancel Mission.
"Python how to achieve computer shutdown at the specified time" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.