Thanks for all yours recommendations, finally I was successfully finished my first project about tkinter (and I hope, not the last).

Here is the finally code:

#!/usr/bin/env python
#
#  DetectConn_2_0.py
#
#

from tkinter import *
import time, socket

def isInternet():
        testConn = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
       # Force a time limit to conect to the host (5 seg), may be more or less
         testConn.settimeout(5)
         output = testConn.connect_ex(('10.44.0.1', 80))
        if output == 0:
            return True
        else:
            return False
        testConn.close()

def colorupdate():
    if isInternet():
        root.config(background="#38EB5C")
    else:
        root.config(background="#F50743")
    root.after(5000, colorupdate)

root = Tk()
root.title("Connection")
root.geometry("80x50")
root.resizable(width=False, height=False)

colorupdate()
root.mainloop()


Thanks again


--

Ing. Jesús Reyes Piedra
Admin Red Neurodesarrollo,Cárdenas
La caja decía:"Requiere windows 95 o superior"...
Entonces instalé LINUX.


--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to