2
這裏是我的代碼:QMessage是一類功能工作正常,但不是在單獨的函數
def er():
print("connection error")
from PyQt5.QtWidgets import QMessageBox
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("Some text ")
msg.setInformativeText("info text")
msg.setWindowTitle("title")
msg.setStandardButtons(QMessageBox.Ok)
retval = msg.exec_()
print(retval)
if __name__ == '__main__':
mac = (':'.join(['{:02x}'.format((getnode() >> i) & 0xff) for i in range(0,8 * 6, 8)][::-1]))
if mac == 'b8:e8:56:24:96:30':
print("OK")
some_function
else:
er()
和錯誤是「QWidget的:前一個QWidget必須構造一個QApplication的」
非常感謝,它的工作原理類似Charm @Tobias – creator