2017-04-09 4 views
0

私は 'automode'を追加したいアプリケーションがあります。QMainWindowはwatchdog.start()でフリーズし、同時に動作させる方法は?

def start_stop_automode(self): 
    self.set_auto() 

    if not self.auto_mode_btn.isChecked() and self.observer.is_alive(): 
     self.observer.stop() 
     self.observer.join() 
     return 
    else: 
     self.observer.start() 
     while True: 
      try: 
      time.sleep(1) 
      except KeyboardInterrupt: 
      self.observer.stop() 
      self.observer.join() 

それは順番にwatchdogeventを引き起こしたファイルにいくつかの機能を実行watchdogFileSystemEventHandlerクラスを開始スロットを呼び出します。 debuggを通じて

class Event(FileSystemEventHandler): 

    def on_created(self, event): 

    input_path = event.src_path 
    if input_path.endswith('_1.CSV'): 

     if self.file_creation_finished(input_path): 
      file = os.path.split(input_path)[-1].rstrip('.CSV') 
      file = file.split('_')[0] 
      self.exec_funk(order=file) 

私はFileSystemEventHandlerクラス内のコードがwatchdogの実行中にQMainWindowの欠けている機能は、実際に運用されて除いて、正しく実行されていることを見ました。 どうすれば両方に対応できますか?

答えて

0

さて、ソリューションがどれほどシンプルであるかを理解してから、while loopを削除して、QMainWindowで作業できます。

関連する問題