需要安装clipboard库和tkinter库,命令如下:
pin install clipboard
pip install tkinter
话不多说上代码:
[Python] 纯文本查看 复制代码 import tkinter as tk
import tkinter.scrolledtext as scrolledtext
import tkinter.messagebox as messagebox
import clipboard
def get_clipboard_history():
history = clipboard.paste()
return history
def show_clipboard_history():
history = get_clipboard_history()
messagebox.showinfo("Clipboard History", history)
def clear_clipboard():
clipboard.copy('')
messagebox.showinfo("Clipboard Cleared", "清理完毕.")
# 创建主窗口
window = tk.Tk()
window.title("查看剪切板历史记录 by:大白baymax")
window.geometry("500x500")
# 创建文本框
text_area = scrolledtext.ScrolledText(window, wrap=tk.WORD)
text_area.pack(expand=True, fill='both')
# 创建按钮
btn_show_history = tk.Button(window, text="显示记录", command=show_clipboard_history)
btn_show_history.pack(pady=10)
btn_clear_clipboard = tk.Button(window, text="清除记录", command=clear_clipboard)
btn_clear_clipboard.pack(pady=10)
# 运行主循环
window.mainloop()
上个主程序的图吧:
最后是打包成EXE的文件:
链接:https://pan.baidu.com/s/1elL09iRYwy6kuZ25xWCTgA
提取码:oms3
|