简体   繁体   English

Python PyQt4 .connect()中的2条或更多命令

[英]Python PyQt4 2 or more Commands in a .connect()

I am using Pyqt4 and I'm trying to make 2 commands work in one .connect() 我正在使用Pyqt4,并且正在尝试使2个命令在一个.connect()中工作

What I have tried has failed me. 我尝试过的失败了。 Here is my code so far: 到目前为止,这是我的代码:

def startSreachBIT(self):
    self.Sreach = UISreach(self)
    self.setCentralWidget(self.Sreach)
    self.Sreach.B64BIT.clicked.connect(self.ButtonC1 + self.startUIToolTab)
    self.Sreach.B32BIT.clicked.connect(self.ButtonC12 + self.startUIToolTab)
    self.show()

you could have a function that calls both. 您可以有一个同时调用两者的函数。 for example: 例如:

def func(self):
    self.func1()
    self.func2()
def startSreachBIT(self):
   self.Sreach.B32BIT.clicked.connect(self.func)

if you want them to happen at the same time you could use threads but I recommend against. 如果希望它们同时发生,则可以使用线程,但我建议不要这样做。

我认为您想要的是QSignalMapper

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM