【Python小案例】打工人必备:有了这款倒计时神器,再也不用担心自己的隐私被偷窥啦~(附源码)
发布人:shili8
发布时间:2023-04-11 02:24
阅读次数:27
前言
又见面了,小伙伴儿们,发现最近大家喜欢看一些简单的小案例?!
咳咳,下面进入正题。
每个人的电脑里都会有不想让别人知道的隐私,或者是上班时间偷偷摸鱼怕被发现的小秘密。
那怎么办?就干脆把隐私锁起来!从源头上杜绝被他人偷窥自己的隐私。
今天小编教大家一键电脑锁屏神器,超级好用~
所有文章完整的素材+源码都在👇👇
粉丝白嫖源码福利,请移步至CSDN社区或文末公众hao即可免费。
正文
1)主要介绍了python实现windows倒计时锁屏功能,代码简单易懂,非常不错,具有一定的
参考借鉴价值,需要的朋友可以参考下:
python实现实windows倒计时锁屏功能
# 倒计时锁屏
import time
from ctypes import *
def closewindows(closetime):
while closetime>0:
print(closetime)
time.sleep(1)
closetime-=1
user32 = windll.LoadLibrary('user32.dll')
user32.LockWorkStation()
if __name__ == "__main__":
closewindows(3)
2)知识点扩展
Python在windows锁屏的代码
C:\Users\HAS>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> user32 = windll.LoadLibrary('user32.dll')
>>> user32.LockWorkStation()
3)python实现倒计时小工具
#!/usr/bin/env python
# coding=utf-8
import threading
import time
import Queue
from Tkinter import *
import tkMessageBox
import logging
logging.basicConfig(level=logging.INFO)
## Communication queue
commQueue = Queue.Queue()
g_time = 0
## Function run in thread
def timeThread():
global g_time
g_time = timeVar.get() * 60
while 1:
logging.info("线程放入队列:%d".decode("utf-8") % g_time)
commQueue.put(g_time)
try:
root.event_generate('<<TimeChanged>>', when='tail')
except TclError:
break
time.sleep(1)
g_time -= 1
if g_time==-1:
begin_btn["fg"] = "black"
clockVar.set("开始计时")
break
def timeChanged(event):
x = commQueue.get()
logging.info("获取队列:%d".decode("utf-8") % x)
minits = x//60
seconds = x%60
s = "剩余时间 {:02}:{:02}".format(minits, seconds)
begin_btn["fg"] = "blue"
clockVar.set(s)
if x==0:
tkMessageBox.showinfo("提醒","时间已到")
def clock_func(*args):
global g_time
if threading.activeCount()>1:
g_time = timeVar.get() * 60
else:
th=threading.Thread(target=timeThread)
th.start()
## Create main window
root = Tk()
root.title("计时工具")
root.geometry("180x95-0-45")
root.resizable(width=FALSE,height=FALSE)
root.wm_attributes("-topmost",1)
frame = Frame(root)
frame.pack()
Label(frame,text="设定时间间隔").grid(row=1,column=2)
timeVar = IntVar()
clockVar = StringVar()
time_entry = Entry(frame, textvariable=timeVar, width=8)
time_entry["justify"] = "center"
time_entry.grid(row=2,column=2,sticky="W,E")
begin_btn = Button(frame,textvariable=clockVar,command=clock_func)
begin_btn.grid(row=3,column=2)
timeVar.set(8)
begin_btn["fg"] = "black"
clockVar.set("开始计时")
for child in frame.winfo_children():
child.grid_configure(pady=3)
time_entry.focus()
root.bind('<<TimeChanged>>', timeChanged)
root.bind("<Return>",clock_func)
root.mainloop()
总结
好啦,今天的内容就到这里正是结束,再也不用担心自己的电脑屏幕一直亮着了~
自动倒计时锁屏, 你值得拥有!
完整的素材源码等:可以滴滴我吖!或者点击文末hao自取免费拿的哈~
🔨推荐往期文章——
项目0.9 【Python实战】WIFI密码小工具,甩万能钥匙十条街,WIFI任意连哦~(附源码)
项目1.0 【Python实战】再分享一款商品秒杀小工具,我已经把压箱底的宝贝拿出来啦~
项目1.5 【Python实战】年底找工作,年后不用愁,多个工作岗位随你挑哦~
项目1.6 【Python实战】听书就用它了:海量资源随便听,内含几w书源,绝对精品哦~
🎁文章汇总——
Python文章合集 | (入门到实战、游戏、Turtle、案例等)
(文章汇总还有更多你案例等你来学习啦~源码找我即可免费!)