Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_multi_clipboard.py ZZZ
- import tkinter as tk
- root = tk.Tk()
- root.title("tk_multi_clipboard")
- copied_texts = []
- toplabel = tk.Label()
- toplabel.pack()
- label2 = tk.Label()
- label2.pack()
- auto_saved_label = tk.Label(toplabel, text="Auto-Saved Clipboard Contents (30 MAX):"+" "*112)
- auto_saved_label.pack(side='left', anchor='w')
- clipboard_label = tk.Label(toplabel, text="Preset Clipboard Contents:")
- clipboard_label.pack(side='left', anchor='e')
- clipboard_contents = tk.Listbox(label2, width=60, height=30)
- clipboard_contents.pack(side='left')
- copied_texts_listbox = tk.Listbox(label2, width=60, height=30)
- copied_texts_listbox.pack(side='right')
- copy_button = tk.Button(root, text="Copy To Preset", command=lambda: copy_to_list())
- copy_button.pack(side='left')
- edit_button = tk.Button(root, text="Edit Preset", command=lambda: edit_text())
- edit_button.pack(side='right')
- delete_button = tk.Button(root, text="Delete Preset", command=lambda: delete_text())
- delete_button.pack(side='right')
- def copy_to_list():
- clipboard_data = root.clipboard_get()
- if clipboard_data not in copied_texts:
- copied_texts.append(clipboard_data)
- copied_texts_listbox.delete(0, tk.END)
- for text in copied_texts:
- copied_texts_listbox.insert(tk.END, text)
- del copied_texts[:-30]
- def edit_text():
- selection = copied_texts_listbox.curselection()
- if selection:
- selected_text = copied_texts_listbox.get(selection[0])
- clipboard_contents.delete("1.0", tk.END)
- clipboard_contents.insert("1.0", selected_text)
- copied_texts.remove(selected_text)
- def delete_text():
- selection = copied_texts_listbox.curselection()
- if selection:
- selected_text = copied_texts_listbox.get(selection[0])
- copied_texts.remove(selected_text)
- copied_texts_listbox.delete(0, tk.END)
- for text in copied_texts:
- copied_texts_listbox.insert(tk.END, text)
- root.mainloop()
- '''
- root.clipboard_get()
- root.clipboard_clear()
- root.clipboard_append("Hello World")
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement