Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import urllib
  2. import urllib.request as url
  3. from tkinter import *
  4.  
  5. master = Tk()
  6. master.geometry("250x50")
  7. master.resizable(False, False)
  8. master.config(bg="#4b4b4b")
  9. master.overrideredirect(True)
  10. master.wm_geometry("-0-40")
  11.  
  12. connectStatus = Label(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
  13. connectStatus.place(x=10,y=8)
  14.  
  15. def runRefresh():
  16. print("Checking")
  17. connectStatus.config(bg="yellow", fg="#fff", width=28, height=2, text="Pending", font="Bahnscrift 10")
  18. attemptConnect()
  19.  
  20. def attemptConnect():
  21. try:
  22. ping = url.urlopen("https://stackoverflow.com", timeout=1)
  23. connectStatus.config(text="Connected", font="Bahnscrift 10", bg="green")
  24. return True
  25.  
  26. except urllib.error.URLError:
  27. connectStatus.config(text="Not Connected", bg="#ff4d4d", font="Bahnscrift 10")
  28. return False
  29.  
  30. master.after(1000, runRefresh)
  31. master.mainloop()
Add Comment
Please, Sign In to add comment