Python Subprocess with Tkinter Problem
by osmantugras from LinuxQuestions.org on (#5BKNG)
Hi All,
When I am writing the python script on Ubuntu, I have faced the issue that is the screenshot on the attachment. Could you please help me?
:) Regards
#########################################
import tkinter as tk
import subprocess
def Delay(X, Y):
subprocess.run(["tc qdisc add dev", X, "root", "netem delay", Y], shell=True)
return
def ping():
subprocess.run("ping {} -c 2".format(entry1.get()), shell=True)
return
my_gui = tk.Tk()
entry1 = tk.StringVar()
entryI = tk.StringVar()
entryT = tk.StringVar()
my_gui.geometry('500x500')
my_gui.title("Ping Delay")
tk.Label(my_gui, text="Enter target IP or host as required.").pack()
tk.Entry(my_gui, textvariable=entry1).pack()
tk.Label(my_gui, text="Enter target Interface").pack()
entryI = tk.Entry(my_gui, textvariable=entryI).pack()
tk.Label(my_gui, text="Enter Delay Value").pack()
entryT = tk.Entry(my_gui, textvariable=entryT).pack()
tk.Button(my_gui, text="Delay", command=lambda: Delay(entryI, entryT)).pack()
tk.Button(my_gui, text="ping", command=ping).pack()
my_gui.mainloop()
#######################################################
Attached Thumbnails
Attached Files


When I am writing the python script on Ubuntu, I have faced the issue that is the screenshot on the attachment. Could you please help me?
:) Regards
#########################################
import tkinter as tk
import subprocess
def Delay(X, Y):
subprocess.run(["tc qdisc add dev", X, "root", "netem delay", Y], shell=True)
return
def ping():
subprocess.run("ping {} -c 2".format(entry1.get()), shell=True)
return
my_gui = tk.Tk()
entry1 = tk.StringVar()
entryI = tk.StringVar()
entryT = tk.StringVar()
my_gui.geometry('500x500')
my_gui.title("Ping Delay")
tk.Label(my_gui, text="Enter target IP or host as required.").pack()
tk.Entry(my_gui, textvariable=entry1).pack()
tk.Label(my_gui, text="Enter target Interface").pack()
entryI = tk.Entry(my_gui, textvariable=entryI).pack()
tk.Label(my_gui, text="Enter Delay Value").pack()
entryT = tk.Entry(my_gui, textvariable=entryT).pack()
tk.Button(my_gui, text="Delay", command=lambda: Delay(entryI, entryT)).pack()
tk.Button(my_gui, text="ping", command=ping).pack()
my_gui.mainloop()
#######################################################
Attached Thumbnails
![]() | PingDelay.txt (868 Bytes) |