Skip to navigation
How to show real time command line output to a tkinter widget
07.12.13
example to create a cd image with the mkisofs.exe called by a python tkinter script: self.message is self.message = Text(frame,height=2,width=38) def burn_cd(self): if(self.c.set_settings(self)): print self.myrun('mkisofs.exe -V testcd -allow-lowercase -joliet-long -input-charset UTF-8 -r -o iso/cd.iso cd',self.message,' extents written ') def myrun(self,cmd,msg,k): success = 0 p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) stdout = [] while True: line = p.stdout.readline() stdout.append(line) if(len(line) > 0 ): msg.delete("1.0","end-1c") msg.insert(INSERT, line) msg.update_idletasks() if(k in line): success = 1 #print line, if line == '' and p.poll() != None: break return success http://www.saltycrane.com/blog/2009/10/how-capture-stdout-in-real-time-python/
Reply
Anonymous
Information Epoch 1732510394
Effectiveness beats efficiency.
Home
Notebook
Contact us