osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tkinter


Thanks, I was noted it. I have figure out, how can I do that.

I keep in touch


El 18/03/19 a las 14:09, MRAB escribi?:
> On 2019-03-18 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")
>>
> You have a problem here: the loop will repeat forever, so you'll never 
> reach the root.mainloop() line and show the GUI.
>
>> 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.
>>

-- 

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/