Estoy realizando una gui en tkinter la cual realiza un ping test a una IP "X" la gui tiene 2 botones que en caso de el ping ser verdadero se pone verde y en caso contrario rojo.
La problematica es que quiero agregar 2 botones mas y 1 entry, lo realize pero no logro que se realice los 2 ping en simultaneo.
les dejo el codigo.
import subprocess as sub
import tkinter as tk
from tkinter import *
class test (tk.Tk):
def ping(self):
try:
self.withdraw()
result=sub.Popen(["ping", "-n", "1", "-w", "1500", conf_ip.get()],shell=True).wait()
if result == 0:
# print ('Active')
B = btn_ping
B ['bg'] = 'green'
B2 = btn_ping2
B2 ['bg'] = 'white'
else:
# print ('Inactive')
B2 = btn_ping2
B2 ['bg'] = 'red'
B = btn_ping
B ['bg'] = 'white'
self.after(1500, self.ping)
except:
quit()
def __init__(self):
tk.Tk.__init__(self)
global conf_ip, ping_ip,btn_ping,btn_ping2, window
window = tk.Tk()
window.title("Ping Aplicacion")
window.attributes('-topmost',True)
window.geometry('375x300')
window.eval('tk::PlaceWindow . center')
lbl = Label(window, text='Ping 1')
lbl.grid(row=0, column=1)
ping_ip= StringVar()
btn_ping= Button(window, text='Online')
btn_ping.config(width=25, height=1)
btn_ping.grid(row=4, column=1)
btn_ping2= Button(window, text='Offline')
btn_ping2.config(width=25, height=1)
btn_ping2.grid(row=4, column=4)
conf_ip = Entry(window, state='normal', textvariable=ping_ip)
conf_ip.grid(row=6, column=1)
conf_ip.insert(END, '127.0.0.1')
ping_ip.set('IP')
app = test()
app.ping()
app.mainloop()