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


On Tue, Mar 19, 2019 at 4:55 AM Informatico de Neurodesarrollo
<infneurodcr.mtz at infomed.sld.cu> wrote:
> This code work fine, every 5 second test the connection to this machine
> ( on my network.
> def isInternet():
>      testConn = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
>      output = testConn.connect_ex(('', 80))
>      if output == 0:
>          return True
>      else:
>          return False
>      testConn.close()
> while True:
>      if isInternet():
>          print("Hay conexi?n")
>      else:
>          print("No hay conexi?n")
>      time.sleep(5)
> What's next?, I am all eyes

Great! Now that that's working, you can go grab your Tkinter code
back. But you'll have to rework things. Set your networking code
aside, and just make something that, every five seconds, changes its
background colour. You may want to do some research on how to do that
reliably. Hint: you most likely won't have a "while" loop in your
final code.

Once you have both parts working separately, then you can put them
together, by having the background colour change be controlled by the
connection check. But first make sure that they work on their own.