# Para instalar tkinter en Ubuntu (UI Python3)
# apt install tk
# apt install python3-tk
# python3 Tkinter
#
# Instalar para Anaconda:
# conda install -c anaconda tk

import requests
from tkinter import Tk, Label, Button

IP = "10.177.122.49"

class VentanaEjemplo:
    def __init__(self, master):
        
        self.master = master
        master.title("Interfaz con Python")
        self.etiqueta = Label(master, text="Control de un LED")
        self.etiqueta.pack()

        self.CasaAzulON = Button(master, text="Casa Azul ON", command=self.CasaAzulON)
        self.CasaAzulON.pack()

        self.CasaRojaON = Button(master, text="Casa Roja ON", command=self.CasaRojaON)
        self.CasaRojaON.pack()

        self.CasaVerdeON = Button(master, text="Casa Verde ON", command=self.CasaVerdeON)
        self.CasaVerdeON.pack()

        self.CasaAzulOFF = Button(master, text="Casa Azul OFF", command=self.CasaAzulOFF)
        self.CasaAzulOFF.pack()

        self.CasaRojaOFF = Button(master, text="Casa Roja OFF", command=self.CasaRojaOFF)
        self.CasaRojaOFF.pack()

        self.CasaVerdeOFF = Button(master, text="Casa Verde OFF", command=self.CasaVerdeOFF)
        self.CasaVerdeOFF.pack()

        self.AutoDorado = Button(master, text="Auto Dorado", command=self.AutoDorado)
        self.AutoDorado.pack()

        self.AutoNegro = Button(master, text="Auto Negro", command=self.AutoNegro)
        self.AutoNegro.pack()

        self.AutoRojo = Button(master, text="Auto Rojo", command=self.AutoRojo)
        self.AutoRojo.pack()

        self.LucesCalleON = Button(master, text="Luces calle ON", command=self.LucesCalleON)
        self.LucesCalleON.pack()

        self.LucesCalleOFF = Button(master, text="Luces calle OFF", command=self.LucesCalleOFF)
        self.LucesCalleOFF.pack()

    def CasaAzulON(self):
        print ("http://"+IP+"/ACCION=CasaAzulON")
        requests.get("http://"+IP+"/ACCION=CasaAzulON")

    def CasaAzulOFF(self):
        requests.get("http://"+IP+"/ACCION=CasaAzulOFF")

    def CasaRojaON(self):
        requests.get("http://"+IP+"/ACCION=CasaRojaON")

    def CasaRojaOFF(self):
        requests.get("http://"+IP+"/ACCION=CasaRojaOFF")

    def CasaVerdeON(self):
        requests.get("http://"+IP+"/ACCION=CasaVerdeON")

    def CasaVerdeOFF(self):
        requests.get("http://"+IP+"/ACCION=CasaVerdeOFF")

    def CasaVerdeON(self):
        requests.get("http://"+IP+"/ACCION=CasaVerdeON")

    def AutoRojo(self):
        requests.get("http://"+IP+"/ACCION=AutoRojo")

    def AutoNegro(self):
        requests.get("http://"+IP+"/ACCION=AutoNegro")

    def AutoDorado(self):
        requests.get("http://"+IP+"/ACCION=AutoDorado")

    def LucesCalleON(self):
        requests.get("http://"+IP+"/ACCION=LucesCalleON")

    def LucesCalleOFF(self):
        requests.get("http://"+IP+"/ACCION=LucesCalleOFF")


root = Tk()
miVentana = VentanaEjemplo(root)
root.mainloop()
