On 18/03/2019 16:00, Informatico de Neurodesarrollo wrote: > Hello friends: > > I am a beginner on programming in python. > > I want make a simple program that test continuously (every 5 seg) the > connection to internet and change the background color when are not > available. I try this , but not work properly: > > #!/usr/bin/env python3 > # -*- coding: utf-8 -*- > # > from tkinter import * > import socket, time > > def DetectarConexion(): > testConn = socket.socket(socket.AF_INET,socket.SOCK_STREAM) > try: > testConn.connect(('8.8.8.8', 80)) > testConn.close() > return True > except: > testConn.close() > return False > > root = Tk() > root.title("Conexión") > root.geometry("80x50") > > while True: > if DetectarConexion(): > # Background:Green > root.config(background="#38EB5C") > else: > # Background:Red > root.config(background="#F50743") > time.sleep(5) > > root.mainloop() > > > Any ideas, will be welcome. > > > T.I.A > >
I asked about a tkinter app for a project I am working on a while back , what was suggested (which was a very useful suggestion) is get the routine and feedback working without the GUI first, so in this case a simply python program would ping something ever 5 mins and say if this was successful or not. Not sure if you would ping as such, but if you can get a normal python script to do what you want, then you can add a gui later. hope this helps Paul -- https://mail.python.org/mailman/listinfo/python-list