锐单电子商城 , 一站式电子元器件采购平台!
  • 电话:400-990-0325

「普通人VS程序员」电脑还可以这样关机,神操作 建议阅读

时间:2023-08-04 10:07:00 1004tk2系列圆形连接器

导语

「普通人VS程序员」电脑还可以这样关机,神操作!建议收藏

大家好,我是梦雅。

无论是家用电脑还是公司电脑,定时开关都是一个非常实用的功能,但一般不太关注。定期关机不仅可以延长电脑

大脑的使用寿命也能节省大量电费?~哈哈哈哈

嗨~不,周日休假一天,但公司的电脑大部分朋友都开了一天,有时候放长假的时候电脑开了几天。

这不是吗?隔壁的小妹妹已经被领导发现了,最后一件事落在我手里,开发一个可以定期关闭的

机器的源码项目供大家使用,并提醒大家下班关机!

定时开关机是一个非常简单实用的功能,跟随本文不到10分钟,你就能学会如何操作。~

正文

本文介绍了普通人关机的习惯和程序员关机的方式!

程序员喜欢在关机时附上两个代码tkinter的就用tk喜欢版本pyqt5.用这个版本。两个版本很大

自己爱那个,用那个哈哈~

一、普通人关机

优雅地关机

1)快捷键关机

相信用快捷键关机是大家常用的方法吧?也是最简单方便的方法。

按下快捷键【Alt】+【F4弹出功能对话框,快速关机,快速准确,效率高。

2)关闭任务管理器

这种方法类似于上一个快捷键关机的方法。按下快捷键【Alt】+【Ctrl】+

【Delete】,打开任务管理器,右下角有一个圆形关机按钮,点击关机。

3)设置关机时间

这种方法可以实现定时关机,计算关机的时间。设置完成后,计算机将自动关闭。不再需要了

等了半天,因为电脑关机更新了。按下快捷键【win】+【R】,输入运行对话框《at20:00

shutdown-s》点击确定后,系统将在晚上8点准时关闭。这种方法可以确定关机时间

使用非常方便。

4)鼠标滑动关机

在电脑桌面位置创建一个快捷方式,在出现的对话框内输入“slidetoshutdown下一步。

点击完成即可。

此时,计算机桌面上有一种快速的方法。如果您想在关机时双击此快速方法,将出现以下提示。

已关闭电脑。

二、程序员关机

嘿嘿虽然正常人开关机更方便快捷!但是源码打包成exe点击更方便特别是如果电脑需要几个小时才能关让电脑自动完成任务,然后关机滴滴这个挺方便的也许,应该更方便.jpg 我233333强行解释这是娱乐的代码,哈哈哈哈最后,如果你的时间不是很紧张,想快点python提高,最重要的是不怕吃苦,建议你可以定价(同音):762459510 ,那真的很好,很多人进步很快,需要你不怕吃苦哦!你可以添加它来看看~

1)Pyqt5界面化小程序

1.1 附源码项目

# -*—coding:utf-8 -*-import sysimport os       # Python执行系统命令方法中使用的包from PyQt5 import QtCore,QtGui,QtWidgets  class Ui_shut(object):    #类 继承object类  flag = True  def setupUi(self,shut):  #方法      #设置窗体的大小   shut.setObjectName("shut")   shut.resize(420,180)                shut.setFixedSize(420,180)    self.label = QtWidgets.QLabel(shut)  self.label.setGeometry(QtCore.QRect(40、50、41、51)  #标签位置   self.label.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.label.setObjectName("label")    self.lineEdit = QtWidgets.QLineEdit(shut)  self.lineEdit.setGeometry(QtCore.QRect(70, 50, 71, 41))  self.lineEdit.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.lineEdit.setObjectName("lineEdit")    self.label_2 = QtWidgets.QLabel(shut)  self.label_2.setGeometry(QtCore.QRect(150, 60, 31, 31))  self.label_2.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.label_2.setObjectName("label_2")    self.lineEdit_2 = QtWidgets.QLineEdit(shut)  self.lineEdit_2.setGeometry(QtCore.QRect(180, 50, 71, 41))  self.lineEdit_2.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.lineEdit_2.setObjectName("lineEdit_2")    self.label_3 = QtWidgets.QLabel(shut)  self.label_3.setGeometry(QtCore.QRect(260, 60, 31, 31))  self.label_3.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.label_3.setObjectName("label_3")    self.pushButton = QtWidgets.QPushButton(shut,clicked=self.sd)   #为pushButton增加监听事件click。  self.pushButton.setGeometry(QtCore.QRect(290, 50, 101, 41))  self.pushButton.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.pushButton.setObjectName("pushButton")   self.label_4 = QtWidgets.QLabel(shut)  self.label_4.setGeometry(QtCore.QRect(0, 120, 500, 31))  self.label_4.setFont(QtGui.QFont("Roman times",10,QtGui.QFont.Bold))  self.label_4.setObjectName("label_4")   self.retranslateUi(shut)  QtCore.QMetaObject.connectSlotsByName(shut) #connectSlotsByName是一个QMetaObject静态函数在类中,它的作用是用来将QObject * o里的子QObject根据它的一些信号objectName连接到o的槽上。           def retranslateUi(self,shut):   _translate = QtCore.QCoreApplication.translate  shut.setWindowTitle(_translate("shut", "Windows定时关机器"))  self.label.setText(_translate("shut", "在:"))  self.label_2.setText(_translate("shut", "时"))  self.label_3.setText(_translate("shut", "分"))  self.label_4.setText(_translate("shut", "    请输入关机时间"))  self.pushButton.setText(_translate("shut", "设置"))  def sd(self,shut):         #self.sd触发事件后需要执行的操作。   h = self.lineEdit.text()   m = self.lineEdit_2.text()   if self.flag:    self.flag = False    try:                      #捕获所有异常     os.popen'at'+ h + ':' + m + ' shutdown -s') 
#python执行cmd命令的方法				
self.label_4.setText('    设置成功! 系统将关机在今天 '+h+':'+m)				self.pushButton.setText('移除')				self.lineEdit.clear()				
self.lineEdit_2.clear()			
except:				
self.label_4.setText('Something is wrong~')		
else:			
self.flag = True			
try:				
os.popen('at /delete /yes')				self.label_4.setText('成功,全部移除')				self.pushButton.setText('Set')				
self.lineEdit.clear()				
self.lineEdit_2.clear()			
except:				
self.label_4.setText('Something is wrong')

1.2 效果展示

​2)Tkinter界面化小程序

2.1 附源码项目

from tkinter import ttkimport osimport tkinter.messagebox as message_boxwindows = tkinter.Tk()windows.title("Python定时关机")# window 居中windows.update()  # update window ,must docurWidth = 280  # get current widthcurHeight = windows.winfo_reqheight()  # get current heightscnWidth, scnHeight = windows.maxsize()  # get screen width and height# now generate configuration informationconfig = '%dx%d+%d+%d' % (curWidth, curHeight,                          (scnWidth - curWidth) / 2, (scnHeight - curHeight) / 2)windows.geometry(config)# root 容器root = ttk.LabelFrame(windows, text="关机命令")root.grid(column=0, row=0, padx=15, pady=15)# 提醒文本tkinter.Label(root, text="输入时间").grid(column=0, row=0, sticky=tkinter.W)tkinter.Label(root, text="选择").grid(column=1, row=0)# 存储输入的值time = tkinter.StringVar()unit = tkinter.StringVar()# 输入框time_edit = tkinter.Entry(root, width=10, textvariable=time)time_edit.grid(column=0, row=1, padx=4, sticky=tkinter.W)time_edit.focus()# 下拉单位选择unit_arr = ('时', '分', '秒')unit_chosen = ttk.Combobox(root, width=6, textvariable=unit, state='readonly')unit_chosen['values'] = unit_arrunit_chosen.grid(column=1, row=1)unit_chosen.current(0)def change_edit(to_time):    time_edit.delete(0, 10)    time_edit.insert(0, to_time)    unit_chosen.current(1)# startdef start():    if time.get() and unit.get():        message_box.showwarning("选择完毕", "你的电脑将在多少 %s %s" % (time.get(), unit.get()))        # shutdown 的秒数        count_down_second = int(time.get())        if unit.get() == 'hour':            count_down_second *= 3600        elif unit.get() == 'minute':            count_down_second *= 60        # execute        os.system("shutdown -s -t %s" % count_down_second)        windows.quit()# canceldef cancel():    os.system("shutdown -a")    windows.quit()# start 按钮start_action = tkinter.Button(root, text="START", command=start)start_action.grid(column=2, row=1)# 文本tip_label = tkinter.Label(root, text="倒计时关机")tip_label.grid(row=2, column=0, pady=2)# 快捷选择时间fram = tkinter.Frame(root)fram.grid(row=3, column=0, columnspan=3)# 常用的时间for i in range(2, 7):    button = tkinter.Button(fram, text=str(i * 15) + "min", command=lambda x=i: change_edit(str(x * 15)))    button.grid(row=0, column=i - 2, padx=2, pady=2, sticky=tkinter.W)# cancel 按钮cancel_action = tkinter.Button(root, text="CANCEL", command=lambda: cancel())cancel_action.grid(row=4, column=1, pady=10, sticky=tkinter.W)

2.2 效果展示

总结

好啦,定时关机的小项目就over了。以后记得需要定时关机的就用这款代码哈哈哈~想什么时候关机就什么时候关机嘛

⛳完整的免费源码领取处:

如需完整的项目源码+素材源码基地见:#私信小编06#即可获取免费的福利!

你们的支持是我最大的动力!!记得三连哦~mua 欢迎大家阅读往期的文章哦~

​​

锐单商城拥有海量元器件数据手册IC替代型号,打造电子元器件IC百科大全!

相关文章