Score:1

Keyboard shortcut to convert simplified to traditional Chinese

ni flag

I am trying to create a keyboard shortcut that runs a python script to convert selected simplified Chinese characters into traditional Chinese in the clipboard.

Here are the essential code:

s2t.py

from opencc import OpenCC as CC
import os
import pyperclip
import pymsgbox
import time

cc = CC('s2t')
text = os.popen("xsel -o").read()
rslt = cc.convert(text)
pyperclip.copy(rslt)
pymsgbox.alert(rslt)

pyperclip.paste()

Though I can get the script to run as expected in a shell terminal with the command below,

/home/username/anaconda3/bin/python3 /home/username/Code/python/general_tools/s2t.py

it doesn't seem to work with the shortcut.

enter image description here


Update:

Most of the code above worked, but I cannot get pyperclip.paste() to run.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.