execute ping command with GUI

前端 未结 3 1473
刺人心
刺人心 2020-12-12 03:39

While writing a GUI application in PyQt5 I encounter weird(for me) behavior. When I wanted to open an information window and start doing another thing after it fully loads.

3条回答
  •  佛祖请我去吃肉
    2020-12-12 04:16

    Here is a single-line solution:

    from PyQt5.QtWidgets import QApplication,QMessageBox
    import sys
    import os
    app = QApplication(sys.argv)
    
    box = QMessageBox()
    box.setText("Text")
    box.show()
    QApplication.processEvents() # <------------ this one
    os.system("ping 8.8.8.8 ")
    
    sys.exit(app.exec())
    

提交回复
热议问题