简单的python代码,使用tkinter库实现交互,定时关机,适用于windows系统。
import os
import sys
import time
import tkinter as tk
from threading import Thread
from tkinter import ttk
def get_time():#获取当前的时间
h=time.strftime("%H", time.localtime())
m=time.strftime("%M", time.localtime())
if len(h)==1:
h="0"+h
if len(m)==1:
h="0"+h
return (h,m)
def close_threading(hour,min):#监测时间并且关机电脑的子线程
global thread_running
bool=True
while bool and thread_running:
time=get_time()
if (time[0]==hour and time[1]==min):
bool=False
if not(bool):
os.system("shutdown -s -t 0")#cmd关机命令
threading=True#控制时间检测线程
def window2(hour,min,root=False):
def open_window1(root):
global thread_running
thread_running=False
window1(root)
if root!=False:
for i in root.winfo_children():
i.destroy()
else:
root = tk.Tk()
global thread_running
t

最低0.47元/天 解锁文章
1230

被折叠的 条评论
为什么被折叠?



