def initUI(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
###########
combo = QComboBox(self)
shotcut_list = [
"Key.f9",
"Key.f2",
"Key.f3",
"Key.f4",
"Key.f5",
"Key.f6",
"Key.f7",
"Key.f8",
"Key.f1",
"Key.f10",
"Key.f11",
"Key.f12",
combo.addItems(shotcut_list)
global shortcut
global cptext
shortcut = combo.currentText()
combo.setGeometry(350, 120, 120, 30)
combo.activated[str].connect(self.onChanged)
# Create textbox
self.textbox = QPlainTextEdit(self)
self.textbox.move(20, 160)
self.textbox.setReadOnly(True)
self.textbox.resize(500, 205)
self.setGeometry(70, 70, 540, 388)
self.show()
def onChanged(self, text):
global shortcut
shortcut = text
def update(self):
self.textbox.insertPlainText(cptext)
print(cptext)
def print_key(*self):
print(self[0])
if str(self[1]) == shortcut:
global cptext
cptext = pc.paste()
keyboard.type(cptext)
self.textbox.insertPlainText(
cptext
) # cannot call the text box using self
1
个回答
0
人赞同
是的,
*self
在Python中不是一个 "指针参数",它是对可变数量的参数进行元组解包。试试
def print_key(self, key):