单击按钮时是否可以执行两个功能?我请求你的帮助!
这是我的窗口类:
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)
您可以再次使用连接