import tkinter as tk
import temp
import sys
# Add path to the module
sys.path.append('pap/front_back_sensor/twilio_sensor.py')
# Global variables
global MINANT, MAXANT
# Print current temperature settings
print (temp.MAXTEMP, temp.MINTEMP)
## Function to read and store desired temperature
def NEWTEMP():
global MAXANT, MINANT
MAXANT = temp.MAXTEMP
MINANT = temp.MINTEMP
print (MAXANT, MINANT)
temp.MAXTEMP = float(entry1.get())
temp.MINTEMP = float(entry2.get())
print (temp.MAXTEMP, temp.MINTEMP)
print(f"MAXTEMP: {temp.MAXTEMP}, MINTEMP: {temp.MINTEMP}")
label_resultado["text"] = f"Alteração feita para:\nTemperatura Máxima {temp.MAXTEMP}\nTemperatura Mínima {temp.MINTEMP}"
# Function to display previous temperatures
def EXIBETEMP ():
label_resultado["text"] = f"Temperatura Máxima anterior: {MAXANT}\nTemperatura Mínima anterior: {MINANT}"
# Function to set Twilio number
def NUMTWILIO ():
temp.NUM_TELE= str(entry3.get())
label_resultado["text"] = f" O número definido para notificação é : {temp.NUM_TELE} "
def ACCOUNT ():
temp.auth_token = entry4.get()
label_resultado["text"] = f"O Account inserido foi: {temp.account_sid}"
def TOKEN ():
temp.auth_token = entry6.get()
label_resultado ["text"] = f"O Token inserido foi: {temp.auth_token}"
def NUMERO_PI ():
temp.NUMERO_PI = entry6.get ()
label_resultado ["text"] = f"O número do RaspBerry foi inserido, {temp.NUMERO_PI}"
# Create the Tkinter root window
root= tk.Tk()
root.title ("Configurações do Sistema")
# Labels and entries for phone number
label4= tk.Label (root, text= "É necessário um número de telemóvel para receber os alertas. Defina este número com cuidado para evitar transtornos. \nO número definido para notificação é : ")
label4.pack()
entry3= tk.Entry(root)
entry3.pack (padx=10)
# Button to change phone number
botao_alt_num= tk.Button (root, text="Alterar Número", command= NUMTWILIO)
botao_alt_num.pack(pady= 10)
label7 =tk.Label (root, text= "Insira o número disponibilizado pela twilio, para o RaspBerry.")
label7.pack()
entry6 = tk.Entry (root)
entry6.pack ()
botao_NUMERO_PI= tk.Button (root, text= "Inserir", command= NUMERO_PI)
botao_NUMERO_PI.pack(pady= 10)
label5 = tk.Label (root, text= "Insira o Account twilio:")
label5.pack ()
entry4= tk.Entry (root)
entry4.pack()
botao_ACCOUNT= tk.Button (root, text="Inserir", command= ACCOUNT)
botao_ACCOUNT.pack(pady=10)
label6= tk.Label (root, text = "Insira o Token twilio")
label6.pack()
entry5= tk.Entry (root)
entry5.pack ()
botao_TOKEN= tk.Button (root, text= "Inserir", command= TOKEN)
botao_TOKEN.pack (pady= 10)
# Labels and entries for desired temperature
label3= tk.Label (root, text = "A temperatura atual é de:" .format())
label1 = tk.Label (root, text= "Temparatura maxima desejada")
label1.pack ()
entry1= tk.Entry (root)
entry1.pack()
label2= tk.Label(root, text= "Temperatura minima desejada")
label2.pack()
entry2= tk.Entry (root)
entry2.pack()
# Button to update temperature settings
botao_alterar =tk.Button (root, text="Alterar temperatura padrão", command= NEWTEMP)
botao_alterar.pack(pady=10)
# Button to display previous temperatures
botao_exibir = tk.Button(root, text="Exibir temperaturas anteriores", command= EXIBETEMP)
botao_exibir.pack(pady=10)
# Result label to display messages
label_resultado = tk.Label(root, text="")
label_resultado.pack()
# Additional label for number format
label5= tk.Label (root, text = "OBS: O número deve ter o seguinte formato +351XXXXXXXX, \ndeve conter o indicativo telefónico do país, a seguir (sem espaço), dos 8 dígitos telefónicos.")
label5.pack()
# Result label to display messagesr
root.mainloop()