Python打工人必備之windows倒計(jì)時(shí)鎖屏功能的實(shí)現(xiàn)
前言
又見面了,小伙伴兒們,發(fā)現(xiàn)最近大家喜歡看一些簡(jiǎn)單的小案例?!
咳咳,下面進(jìn)入正題。
每個(gè)人的電腦里都會(huì)有不想讓別人知道的隱私,或者是上班時(shí)間偷偷摸魚怕被發(fā)現(xiàn)的小秘密。
那怎么辦?就干脆把隱私鎖起來(lái)!從源頭上杜絕被他人偷窺自己的隱私。
實(shí)現(xiàn)思路
1)主要介紹了python實(shí)現(xiàn)windows倒計(jì)時(shí)鎖屏功能,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下:
python實(shí)現(xiàn)實(shí)windows倒計(jì)時(shí)鎖屏功能
# 倒計(jì)時(shí)鎖屏 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)知識(shí)點(diǎn)擴(kuò)展
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實(shí)現(xiàn)倒計(jì)時(shí)小工具
#!/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("線程放入隊(duì)列:%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("開始計(jì)時(shí)") break def timeChanged(event): x = commQueue.get() logging.info("獲取隊(duì)列:%d".decode("utf-8") % x) minits = x//60 seconds = x%60 s = "剩余時(shí)間 {:02}:{:02}".format(minits, seconds) begin_btn["fg"] = "blue" clockVar.set(s) if x==0: tkMessageBox.showinfo("提醒","時(shí)間已到") 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("計(jì)時(shí)工具") root.geometry("180x95-0-45") root.resizable(width=FALSE,height=FALSE) root.wm_attributes("-topmost",1) frame = Frame(root) frame.pack() Label(frame,text="設(shè)定時(shí)間間隔").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("開始計(jì)時(shí)") 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()
好啦,今天的內(nèi)容就到這里正是結(jié)束,再也不用擔(dān)心自己的電腦屏幕一直亮著了~自動(dòng)倒計(jì)時(shí)鎖屏, 你值得擁有!
到此這篇關(guān)于Python打工人必備之windows倒計(jì)時(shí)鎖屏功能的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Python windows倒計(jì)時(shí)鎖屏內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Flask框架學(xué)習(xí)筆記之表單基礎(chǔ)介紹與表單提交方式
這篇文章主要介紹了Flask框架學(xué)習(xí)筆記之表單基礎(chǔ)介紹與表單提交方式,結(jié)合實(shí)例形式分析了flask框架中表單的基本功能、定義、用法及表單提交的get、post方式使用技巧,需要的朋友可以參考下2019-08-08淺談Pytorch中的torch.gather函數(shù)的含義
今天小編就為大家分享一篇淺談Pytorch中的torch.gather函數(shù)的含義,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2019-08-08python實(shí)現(xiàn)余弦相似度文本比較的示例
這篇文章主要介紹了python實(shí)現(xiàn)余弦相似度文本比較的示例,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-05-05