Skip to content

Instantly share code, notes, and snippets.

@nesffer
Last active August 29, 2015 14:21
Show Gist options
  • Save nesffer/650d7fb74d9794fc452a to your computer and use it in GitHub Desktop.
Save nesffer/650d7fb74d9794fc452a to your computer and use it in GitHub Desktop.
Network Connection Popup
# -*- coding: utf-8 -*-
from time import sleep
from tkinter import messagebox
from urllib.request import urlopen
import urllib.error
def net_connection_on():
try:
response = urlopen('http://example.com', timeout=1)
messagebox.showinfo("네트워크 연결정보", "연결 되었습니다")
return True
except urllib.error.URLError:
pass
return False
if __name__ == "__main__":
while True:
if net_connection_on():
print("Connected Network")
break
else:
print("Failed, wait 3 second...")
sleep(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment