Jun-26-2019, 01:09 PM
HI ,
do anyone knows how to place clear button next to ping button.
Right now it display ping and clear is not place together.
if i put pack(side"left"), it will look really strange.
Is there any method to let ping and clear to be next to each other. Which method should i used?
do anyone knows how to place clear button next to ping button.
Right now it display ping and clear is not place together.
if i put pack(side"left"), it will look really strange.
Is there any method to let ping and clear to be next to each other. Which method should i used?
import tkinter as tk import subprocess def clear_text(): result.destroy() def ping(): cmd = ["ping", entry.get(), "-c", "2"] output = subprocess.check_output(cmd) #output = subprocess.check_output("ping {} -c 2".format(entry.get()), shell=True) #print under console #print('>', output) #with open('test.txt', 'w') as f: #cls print(output, file=f) # put result in label result['text'] = output.decode('utf-8') my_gui = tk.Tk() entry = tk.StringVar() my_gui.geometry('300x300') my_gui.title("Get output inside GUI") tk.Label(my_gui, text="Enter target IP or host as required.",bg = 'red').pack(side='top') tk.Entry(my_gui, textvariable=entry).pack() tk.Button(my_gui,text="Ping Test", command=ping).pack() tk.Button(my_gui,text="Clear", command=clear_text).pack() # label for ping result result = tk.Label(my_gui) result.pack(side='bottom') my_gui.mainloop()