Python, Tkinter, Subprocess- getting stdout and inserting it to Text
Question: Have mercy, I'm a beginner.

I'm trying to write a very basic application to run 'chkdsk c:' and print out
the output to a text box line by line. for each line I want a ttk.Progressbar
to move a bit. I've seen similar questions answered here, but couldn't get
them to work. I got this far:

    
    
    from Tkinter import *
    import ttk
    from subprocess import Popen, PIPE
    
    gui = Tk()
    
    text = Text(gui)
    lb = ttk.Label(text="Chkdsk")
    prog = ttk.Progressbar(mode='indeterminate')
    
    def chkdsk():
        proc = Popen(['chkdsk','c:'],stdout=PIPE)
        while True:
            line = proc.stdout.readline()
            if line != '':
                text.insert(INSERT, "\n")
                text.insert(END, line.rstrip())
                prog.step(1)
                gui.update()
            else:
                break
    
    bt = ttk.Button(text="Chkdsk", command=chkdsk).grid(row=4, column=5)
    
    text.grid(row=6, column= 5)
    lb.grid(row=3, column=5)
    prog.grid(row=7,column=5)
    mainloop()
    

Ok, so when I run this .pyw script on an **elevated command prompt(this is
good for my purposes)** \- "python chkdsk.pyw" and initiate the chkdsk, it
starts working, and then shortly thereafter becomes non responding.

I believe the problem has something to do with buffering?


Answer: `readline` is blocking. Use non-blocking `read` and the `after`-method.

