summaryrefslogtreecommitdiff
path: root/Chap8PracMcbDelete.pyw
diff options
context:
space:
mode:
authormlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
committermlot <petri-rush-curvy@duck.com>2025-06-06 13:40:57 -0400
commit75a42ec54dbf721caa659ddf02c1f46fc2cb4bef (patch)
tree84be794a2481e356a7784557a6f9fb6fbf29cfdd /Chap8PracMcbDelete.pyw
initial commit for archivingHEADmain
Diffstat (limited to 'Chap8PracMcbDelete.pyw')
-rw-r--r--Chap8PracMcbDelete.pyw34
1 files changed, 34 insertions, 0 deletions
diff --git a/Chap8PracMcbDelete.pyw b/Chap8PracMcbDelete.pyw
new file mode 100644
index 0000000..5dc8e40
--- /dev/null
+++ b/Chap8PracMcbDelete.pyw
@@ -0,0 +1,34 @@
+#! ptyhon3
+
+# Chapter 8 Practice Project
+# Extend the Multiclipboard project to include a delete option
+
+
+# Loads and saves clipboard text based on a key word from the command line
+# Usage: py.exe mcb.pyw save <keyword> - Saves to clipboard
+# py.exe mcb.pyw <keyword> - Loads keyword to clipboard
+# py.exe mcb.pyw list - Loads all keywords to clipboard
+# py.exe mcb.pyw delete - Deletes all keywords
+# py.exe mcb.pyw delete <keyword> - Deletes a specific keyword
+
+import sys
+import pyperclip
+import shelve
+
+mcbShelf = shelve.open('mcb')
+
+if len(sys.argv) == 3 and sys.argv[1].lower() == 'save':
+ mcbShelf[sys.argv[2]] = pyperclip.paste()
+elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete':
+ del mcbShelf[sys.argv[2]]
+elif len(sys.argv) == 2:
+ if sys.argv[1].lower() == 'list':
+ pyperclip.copy(str(list(mcbShelf.keys())))
+ elif sys.argv[1].lower() == 'delete':
+ for k in list(mcbShelf.keys()):
+ del mcbShelf[k]
+ elif sys.argv[1] in mcbShelf:
+ pyperclip.copy(mcbShelf[sys.argv[1]])
+
+
+mcbShelf.close()