I am currently working on the Book Automate the Boring Stuff Chapter 9 the Practice Project Extending the Multi-Clipboard.
Code:
#! python3
# mcb.pyw - Saves and loads peices of text to the clipboard
# Usage: py.exe mcb.pyw save <keywoard> - Saves clipboard to key keywoard
# py.exe mcb.pyw <keywoard> - Loads keywoards to clipboard
# py.exe mcb.pyw list - Loads all keywoards to clipboard
import shelve
import pyperclip
import sys
mcbShelf = shelve.open('mcb')
helpList = []
# Save clipboard content
if len(sys.argv) == 3:
if sys.argv[1].lower == 'save':
mcbShelf[sys.argv[2]] = pyperclip.paste()
elif sys.argv[1].lower == 'delete':
if sys.argv[2] == 'all':
for key, balue in mcbShelf.items():
helpList.append(key)
for i in range(len(helpList)):
del mcbShelf[helpList[i]]
if sys.argv[2] in mcbShelf:
del mcbShelf[sys.argv[2]]
elif sys.argv[1].lower == 'add':
mcbShelf[sys.argv[2]] = pyperclip.paste()
elif len(sys.argv) == 2:
# List keywoards and load content
if sys.argv[1].lower == 'list':
pyperclip.copy(str(list(mcbShelf.keys())))
elif sys.argv[1] in mcbShelf:
pyperclip.copy(mcbShelf[sys.argv[1]])
mcbShelf.close()
When I start the program from my command prompt for example with "py mcb.py list" absolutely nothing happens I just go to the next line in my command prompt without an error message.
I only have this problem in my programs with pyperclip and sys.argv. If I only use pyperclip it seems to work properly any ideas how to fix the issue?