Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib
- import urllib.request as url
- from tkinter import *
- master = Tk()
- master.geometry("250x50")
- master.resizable(False, False)
- master.config(bg="#4b4b4b")
- master.overrideredirect(True)
- master.wm_geometry("-0-40")
- connectStatus = Label(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
- connectStatus.place(x=10,y=8)
- def runRefresh():
- print("Checking")
- connectStatus.config(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
- attemptConnect()
- def attemptConnect():
- try:
- ping = url.urlopen("https://stackoverflow.com", timeout=1)
- connectStatus.config(text="Connected", font="Bahnscrift 10", bg="green")
- return True
- except urllib.error.URLError:
- connectStatus.config(text="Not Connected", bg="#ff4d4d", font="Bahnscrift 10")
- return False
- master.after(1000, runRefresh)
- master.mainloop()
Add Comment
Please, Sign In to add comment