无法使用指针参数在python中调用函数
是的,无法使用指针参数在python中调用函数,python,pyqt5,Python,Pyqt5,是的,*self在Python中不是一个“指针参数”,它是为变量数解包的元组。试一试 class X: def initUI(self): self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) ########### combo = QComboBox(self) shotc
*self
在Python中不是一个“指针参数”,它是为变量数解包的元组。试一试
class X:
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
相反(或者如果
print_-key
被发送了更多您不关心的参数,print_-key(self,key,*args)
)…是因为Python没有指针吗?def print_-key(*self):print(self[0])如果str self[1])=快捷方式:全局cptext cptext=pc.paste()keyboard.type(cptext)self.textbox.insertPlainText(cptext)def key(self):listener=listener(on_press=self.print_key)listener.start()@AshfaqueKhan我不知道该如何理解这条评论。非常感谢你,我在这个伟大的帮助中开始了新的一步
def print_key(self, key):
print(self)
if str(key) == shortcut:
# ...