execute ping command with GUI

前端 未结 3 1469
刺人心
刺人心 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 03:55

    As an option. Try it:

    import sys
    import os
    from PyQt5.QtWidgets import QApplication,QMessageBox
    from PyQt5.QtCore import QTimer
    
    app = QApplication(sys.argv)
    
    box = QMessageBox()
    box.setText("Text")
    box.show()
    
    def osSystem():
        os.system("ping 8.8.8.8 ") 
    
    QTimer.singleShot(20, osSystem )
    
    #os.system("ping 8.8.8.8 ")
    
    
    sys.exit(app.exec())
    

提交回复
热议问题