realtime output of subprocess with tkinter

Viewed 28

Hello guys i have got a problem with tkinter and subprocess

    from msilib import text
import subprocess
import threading
import tkinter as tk



output = ""

    

def traccert():
    inputfield1out = inputfield1.get()
    cmdin = "tracert " + inputfield1out
    cmdoutput = subprocess.Popen(cmdin,shell=True, stdout=subprocess.PIPE)
    output = cmdoutput.stdout.read()
    textoutputlabel.config(text=output)

    
    

def ipconfig():
    cmdin = "ipconfig"
    cmdoutput = subprocess.Popen(cmdin,shell=True, stdout=subprocess.PIPE)
    output = cmdoutput.stdout.read()
    textoutputlabel.config(text=output)












fenster = tk.Tk()

inputfield1 = tk.Entry(fenster)
bttraccert = tk.Button(fenster,text="tracert",command= traccert)
textoutputlabel = tk.Label(fenster, text= "run a command and you can see here the output of the console")
btipconfig = tk.Button(fenster,text="Ipconfig",command=ipconfig)

inputfield1.pack()
bttraccert.pack()
btipconfig.pack()
textoutputlabel.pack()
fenster.mainloop()

When i run it it gots stuck (in windows) and there is no respons for a few seconds.

I want to have an live output console

Please help me.

Thank you.

0 Answers
Related