Как запустить 2 или более функций при нажатии одной кнопки PyQt5?
Возможно ли, чтоб при нажатии на кнопку выполнялись две функции? Прошу Вашей помощи!
Вот мой класс окна:
class Window_3(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_regit()
self.ui.setupUi(self)
self.ui.pushButton3.clicked.connect(self.go_end)
self.ui.pushButton4.clicked.connect(self.processor) # хочу вызвать processor и matherboard
def go_end(self):
self.hide()
def processor(self):
name_proc = "ProcessorNameString"
n_p = True
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0") as sub_key:
try:
i = 0
while n_p:
path_value = winreg.EnumValue(sub_key, i)
if name_proc == path_value[0]:
self.ui.label_proc_info.setText(f"{path_value[1]}")
print(f"Proseccor: {path_value[1]}")
n_p = False
else:
i += 1
except OSError:
print("processor not found")
winreg.CloseKey(sub_key)
winreg.CloseKey(hkey)
def matherboard(self):
name_proc = "BaseBoardproduct"
n_p = True
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hkey:
with winreg.OpenKey(hkey, "HARDWARE\\DESCRIPTION\\System\\BIOS\\0") as sub_key:
try:
i = 0
while n_p:
path_value = winreg.EnumValue(sub_key, i)
if name_proc == path_value[0]:
self.ui.label_proc_info_2.setText(f"{path_value[1]}")
n_p = False
else:
i += 1
except OSError:
pass
winreg.CloseKey(sub_key)
winreg.CloseKey(hkey)
Ответы (1 шт):
Автор решения: Aimon Z.
→ Ссылка
Вы можете использовать connect второй раз
self.ui.pushButton4.clicked.connect(self.processor)
self.ui.pushButton4.clicked.connect(self.matherboard)