I started the timer and connect to function call “read_file” at interval 1sec. However, GUI interface does not come up. I do not understand on how Python QTimer and QT GUI work together? What can I do so my GUI page pop up and display the ping status. Any help I would appreciated.
import sys
from reachable_gui import *
import subprocess
import threading
import time
from PyQt5.QtCore import QTimer
import os
def signal(self):
self.Button_Manual.clicked.connect(Manual)
self.Button_Pdf.clicked.connect(Pdf)
read_file(self)
def Manual():
pass
def Pdf():
pass
def read_file(self):
{
#read line by line IP and device from a file and pass it to ping()
}
timer = QtCore.QTimer()
timer.timeout.connect(self.read_file)
timer.setInterval(1000)
timer.start()
def ping(self,IP,name):
{
# ping the device and update GUI status.
}
Ui_MainWindow.ping = ping
Ui_MainWindow.signal = signal
Ui_MainWindow.Manual = Manual
Ui_MainWindow.Pdf = Pdf
Ui_MainWindow.read_file = read_file
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
ui.signal()
MainWindow.show()
sys.exit(app.exec_())
I don't know if this helps you resolve your problem but this is example how to use
QTimerto run function many times.But if function runs longer then it may create longer interval.