Oct-07-2021, 01:57 AM
(This post was last modified: Oct-07-2021, 01:57 AM by deanhystad.)
I took this answer for a related question.
https://stackoverflow.com/questions/6884...hdog-on-qt
And maybe modified it to work with your code. I do not have the watchdog module installed and I don't know anything about your image analyzer. Really untested code here:
https://stackoverflow.com/questions/6884...hdog-on-qt
And maybe modified it to work with your code. I do not have the watchdog module installed and I don't know anything about your image analyzer. Really untested code here:
# Many imports class Bridge(QtCore.QObject): '''Serves as a bridge between watchdog thread and Qt thread''' created = QtCore.Signal(FileSystemEvent) class Handler(FileSystemEventHandler): '''watchdog observer event handler''' def __init__(self): super().__init__() self.bridge = Bridge() def on_created(self, event): '''Emit signal when hdf5 file is created''' if event.src_path[-4:] == 'hdf5': self.bridge.created.emit(event) class MyMainWindow(QtGui.QMainWindow, Ui_MainWindow): """My designer created window""" def __init__(self, path): super().__init__() ... # Create observer to signal my new_file method when an # hdf5 file is created in path. handler = Handler() handler.bridge.created.connect(self.new_file) observer = Observer() observer.schedule(handler, path, recursive=True) observer.start() def new_file(self, event): '''Method called when hdf5 file is created. Passed a FileSystemEvent''' print(event.src_path) ... def main(): path = ... app = QtWidgets.QApplication() form = MyMainWindow(path) form.show() app.exec_() if __name__ == '__main__': main()