Am I commenting enough? Are my variables properly following correct styling format? Is there a more efficient way to code my Label coloring conditions?from tkinter import *import subprocessimport rerunning = False # Infinite loop conditionidle_status = 'To begin, please press Start' # Message for Idle Status# Start, Stop & Scanning functionsdef start():    Status.configure(text='Loading, please wait...')    global running    running = Truedef stop():    global running    running = False    Status.configure(text=idle_status, background=Grey)    StatusPing.configure(text=, background=Grey)def scanning():    if running:        output = subprocess.check_output(ping 104.160.131.1, shell = False, universal_newlines=True).splitlines()        for i in output:            if Packets in i: var1 = int(re.search(r'\d+', str(re.findall(r'Lost =\s\d*',i))).group())            if Minimum in i: var2 = int(re.search(r'\d+', str(re.findall(r'Average =\s\d*',i))).group())    Status.configure(text=Packet lost: {0}.format(var1))    StatusPing.configure(text=Average ms: {0}.format(var2))    # Packet loss label coloring    if var1 == 0:        Status.configure(background=Green)    else:        Status.configure(background=Red)    # Ping Status label coloring    if var2 <= 35:        StatusPing.configure(background=Green)    if 35 < var2 < 70:        StatusPing.configure(background=Yellow)    if var2 >= 70:        StatusPing.configure(background=Red)    root.after(10000, scanning)# GUIroot = Tk()root.geometry(200x120)root.wm_title(Ping Checker)# Ping Check LabelStatus = Label(root, text = idle_status, height=0, width=30, background=Grey)Status.pack(pady=1) # For visible division between two labelsStatusPing = Label(root, height=0, width=30, background=Grey)StatusPing.pack()# Start & Stop ButtonsStart = Button (root, text = Turn on, command = start).pack()Stop = Button (root, text = Turn off, command = stop).pack()root.after(10000, scanning) # Global Looproot.mainloop()
Automatic ping check program
python;beginner;python 3.x;tkinter;status monitoring