日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

dell筆記本死機(jī)無(wú)法強(qiáng)制關(guān)機(jī) 筆記本強(qiáng)制關(guān)機(jī)電腦快捷鍵( 二 )


該更方便.jpg 強(qiáng)行解釋的我2333~這就是娛樂(lè)娛樂(lè)的代碼哈哈哈哈~
1)Pyqt5界面化小程序
1.1 附源碼項(xiàng)目
# -*—coding:utf-8 -*-import sysimport os# Python執(zhí)行系統(tǒng)命令方法所用到的包from PyQt5 import QtCore,QtGui,QtWidgetsclass Ui_shut(object):#類(lèi) 繼承object類(lèi) flag = True def setupUi(self,shut):#方法#設(shè)置窗體的大小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)) #標(biāo)簽的位置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添加監(jiān)聽(tīng)事件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是一個(gè)QMetaObject類(lèi)里的靜態(tài)函數(shù),其作用是用來(lái)將QObject * o里的子QObject的某些信號(hào)按照其objectName連接到o的槽上 。def retranslateUi(self,shut):_translate = QtCore.QCoreApplication.translateshut.setWindowTitle(_translate("shut", "Windows定時(shí)關(guān)機(jī)器"))self.label.setText(_translate("shut", "在:"))self.label_2.setText(_translate("shut", "時(shí)"))self.label_3.setText(_translate("shut", "分"))self.label_4.setText(_translate("shut", "請(qǐng)輸入關(guān)機(jī)時(shí)間"))self.pushButton.setText(_translate("shut", "設(shè)置")) def sd(self,shut):#self.sd為觸發(fā)該事件后,需要執(zhí)行的操作 。h = self.lineEdit.text()m = self.lineEdit_2.text()if self.flag:self.flag = Falsetry:#捕獲所有異常os.popen('at'+ h + ':' + m + ' shutdown -s') #python執(zhí)行cmd命令的方法self.label_4.setText('設(shè)置成功! 系統(tǒng)將關(guān)機(jī)在今天 '+h+':'+m)self.pushButton.setText('移除')self.lineEdit.clear()self.lineEdit_2.clear()except:self.label_4.setText('Something is wrong~')else:self.flag = Truetry: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 效果展示

dell筆記本死機(jī)無(wú)法強(qiáng)制關(guān)機(jī) 筆記本強(qiáng)制關(guān)機(jī)電腦快捷鍵


?

?2)Tkinter界面化小程序
2.1 附源碼項(xiàng)目
from tkinter import ttkimport osimport tkinter.messagebox as message_boxwindows = tkinter.Tk()windows.title("Python定時(shí)關(guān)機(jī)")# 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="關(guān)機(jī)命令")root.grid(column=0, row=0, padx=15, pady=15)# 提醒文本tkinter.Label(root, text="輸入時(shí)間").grid(column=0, row=0, sticky=tkinter.W)tkinter.Label(root, text="選擇").grid(column=1, row=0)# 存儲(chǔ)輸入的值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 = ('時(shí)', '分', '秒')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 的秒數(shù)count_down_second = int(time.get())if unit.get() == 'hour':count_down_second *= 3600elif unit.get() == 'minute':count_down_second *= 60# executeos.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="倒計(jì)時(shí)關(guān)機(jī)")tip_label.grid(row=2, column=0, pady=2)# 快捷選擇時(shí)間fram = tkinter.Frame(root)fram.grid(row=3, column=0, columnspan=3)# 常用的時(shí)間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)

推薦閱讀