Reputation: 363
If there is no break point - text not copied over to clipboard. If its present - it is. I am on fedora 37, debugging with vs code.
File and repo: https://github.com/kha-white/manga-ocr/blob/master/manga_ocr/ocr.py
Code:
def process_and_write_results(mocr, img_or_path, write_to):
t0 = time.time()
text = mocr(img_or_path)
t1 = time.time()
logger.info(f'Text recognized in {t1 - t0:0.03f} s: {text}')
if write_to == 'clipboard':
pyperclip.copy(text) # <--- here is the function
else:
write_to = Path(write_to)
if write_to.suffix != '.txt':
raise ValueError('write_to must be either "clipboard" or a path to a text file')
with write_to.open('a', encoding="utf-8") as f:
f.write(text + '\n')
Upvotes: 0
Views: 179
Reputation: 363
The issue was the fact that my system uses wayland, and paperclip uses xlip, which works "strangely" for wayland. After installing wl-clipboard
and specifing it - coping works.
pyperclip.set_clipboard("wl-clipboard")
pyperclip.copy(text)
Upvotes: 1