Tk progress bar on GUI while a subprocess is running in the background? Tk progress bar on GUI while a subprocess is running in the background? tkinter tkinter

Tk progress bar on GUI while a subprocess is running in the background?


There is no need to create a thread or spawn another process using multiprocessing module. I created a subprocess.Popen object from the mainloop and created a while loop which checks if the process is alive and updates the root widget if the executable is running. This ensures that the progress bar works until the subprocess is finished or killed.

self.progressBar=Progressbar(self.note,mode='indeterminate',length=500)self.progressBar.grid(row=13,columnspan=6,sticky=W+E,padx=(40,10),in_=self.input_Tab)os.chdir( 'D:\\Projects\\' ) self.proc=subprocess.Popen( "executable.exe" ,shell=False)self.progressBar.start()while self.proc.poll() is None:      self.update()self.progressBar.stop()