rom tkinter import *
from datetime import datetime
import ephem root = Tk()
root.geometry("600x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Calcular Ascendente") titulo = Label(text="Calcular Ascendente",
font=("Arial", "35", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.1, rely=0.05) texto_sub1 = Label(text="Data de nascimento (AAAA-MM-DD):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.3) texto_sub2 = Label(text="Hora de nascimento(h:m:s):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.18, rely=0.4) texto_sub3 = Label(text="Latitude:",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.48, rely=0.5) texto_sub4 = Label(text="Longitude:",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.45, rely=0.6) data_nascimento = StringVar()
data_nascimento_entrada = Entry(textvariable=data_nascimento,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
data_nascimento_entrada.place(relx=0.65, rely=0.3, relwidth=0.3)
data_nascimento_entrada.focus() hora_nascimento = StringVar()
hora_nascimento_entrada = Entry(textvariable=hora_nascimento,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
hora_nascimento_entrada.place(relx=0.65, rely=0.4, relwidth=0.3) Latitude = StringVar()
Latitude_entrada = Entry(textvariable=Latitude,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Latitude_entrada.place(relx=0.65, rely=0.5, relwidth=0.3) Longitude = StringVar()
Longitude_entrada = Entry(textvariable=Longitude,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Longitude_entrada.place(relx=0.65, rely=0.6, relwidth=0.3) def limpar():
Longitude_entrada.delete(0, END)
Latitude_entrada.delete(0, END)
hora_nascimento_entrada.delete(0, END)
data_nascimento_entrada.delete(0, END)
resultado_texto.config(text="") def app():
try:
# Retrieve input values
fecha_nascimento_str = data_nascimento.get()
hora_nascimento_str = hora_nascimento.get()
latitud_str = Latitude.get()
longitud_str = Longitude.get() # Parse date and time
data_hora = datetime.strptime(fecha_nascimento_str + ' ' + hora_nascimento_str, '%Y-%m-%d %H:%M:%S') # Set up ephem observer
observador = ephem.Observer()
observador.lon = str(longitud_str)
observador.lat = str(latitud_str)
observador.date = data_hora # Calculate the Ascendant
sol = ephem.Sun()
sol.compute(observador)
ascendente = ephem.constellation(sol)[1] # Translate Ascendant to Portuguese
traducao_ascendente = traduzir_signo_para_portugues(ascendente) # Update result label
resultado_texto.config(text=f"Ascendente: {traducao_ascendente}") except ValueError:
resultado_texto.config(text="Erro: Verifique os dados fornecidos.")
def traduzir_signo_para_portugues(signo):
traducoes = {
"Aries": "Carneiro",
"Taurus": "Touro",
"Gemini": "Gémeos",
"Cancer": "Caranguejo",
"Leo": "Leão",
"Virgo": "Virgem",
"Libra": "Balança",
"Scorpius": "Escorpião",
"Sagittarius": "Sagitário",
"Capricornus": "Capricórnio",
"Aquarius": "Aquário",
"Pisces": "Peixes"
} return traducoes.get(signo, signo) but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.7, relwidth=0.25, relheight=0.1) but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.7, relwidth=0.25, relheight=0.1) but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.7, rely=0.7, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9, relheight=0.1) root.mainloop()
#Outra Versão
from tkinter import *
from datetime import datetime
import ephem root = Tk()
root.geometry("600x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Calcular Ascendente e Signo") titulo = Label(text="Calcular Ascendente e Signo",
font=("Arial", "30", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05) texto_sub1 = Label(text="Data de nascimento (AAAA-MM-DD):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.3) texto_sub2 = Label(text="Hora de nascimento (HH:MM:SS):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.05, rely=0.4) texto_sub3 = Label(text="Latitude (ex: -23.5505):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.05, rely=0.5) texto_sub4 = Label(text="Longitude (ex: -46.6333):",
font=("Arial", "15", "bold"), bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.05, rely=0.6) data_nascimento = StringVar()
data_nascimento_entrada = Entry(textvariable=data_nascimento,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
data_nascimento_entrada.place(relx=0.65, rely=0.3, relwidth=0.3)
data_nascimento_entrada.focus() hora_nascimento = StringVar()
hora_nascimento_entrada = Entry(textvariable=hora_nascimento,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
hora_nascimento_entrada.place(relx=0.65, rely=0.4, relwidth=0.3) Latitude = StringVar()
Latitude_entrada = Entry(textvariable=Latitude,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Latitude_entrada.place(relx=0.65, rely=0.5, relwidth=0.3) Longitude = StringVar()
Longitude_entrada = Entry(textvariable=Longitude,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Longitude_entrada.place(relx=0.65, rely=0.6, relwidth=0.3) def limpar():
Longitude_entrada.delete(0, END)
Latitude_entrada.delete(0, END)
hora_nascimento_entrada.delete(0, END)
data_nascimento_entrada.delete(0, END)
resultado_texto.config(text="") def calcular_ascendente_signo():
try:
# Retrieve input values
fecha_nascimento_str = data_nascimento.get()
hora_nascimento_str = hora_nascimento.get()
latitud_str = Latitude.get()
longitud_str = Longitude.get() # Parse date and time
data_hora = datetime.strptime(fecha_nascimento_str + ' ' + hora_nascimento_str, '%Y-%m-%d %H:%M:%S') # Set up ephem observer
observador = ephem.Observer()
observador.lon = str(longitud_str)
observador.lat = str(latitud_str)
observador.date = data_hora # Calculate the Ascendant
sol = ephem.Sun()
sol.compute(observador)
ascendente = ephem.constellation(sol)[1] # Determine Zodiac sign based on the Sun's position
zodiac_sign = determinar_signo(data_hora.month, data_hora.day) # Translate Ascendant and Zodiac sign to Portuguese
traducao_ascendente = traduzir_signo_para_portugues(ascendente)
traducao_signo = traduzir_signo_para_portugues(zodiac_sign) # Update result label
resultado_texto.config(text=f"Ascendente: {traducao_ascendente}\nSigno: {traducao_signo}") except ValueError:
resultado_texto.config(text="Erro: Verifique os dados fornecidos.") def determinar_signo(mes, dia):
# Determine Zodiac sign based on month and day
if (mes == 1 and dia >= 20) or (mes == 2 and dia <= 18):
return "Aquarius"
elif (mes == 2 and dia >= 19) or (mes == 3 and dia <= 20):
return "Pisces"
elif (mes == 3 and dia >= 21) or (mes == 4 and dia <= 19):
return "Aries"
elif (mes == 4 and dia >= 20) or (mes == 5 and dia <= 20):
return "Taurus"
elif (mes == 5 and dia >= 21) or (mes == 6 and dia <= 20):
return "Gemini"
elif (mes == 6 and dia >= 21) or (mes == 7 and dia <= 22):
return "Cancer"
elif (mes == 7 and dia >= 23) or (mes == 8 and dia <= 22):
return "Leo"
elif (mes == 8 and dia >= 23) or (mes == 9 and dia <= 22):
return "Virgo"
elif (mes == 9 and dia >= 23) or (mes == 10 and dia <= 22):
return "Libra"
elif (mes == 10 and dia >= 23) or (mes == 11 and dia <= 21):
return "Scorpio"
elif (mes == 11 and dia >= 22) or (mes == 12 and dia <= 21):
return "Sagittarius"
else:
return "Capricorn"
def traduzir_signo_para_portugues(signo):
# Translation dictionary for Zodiac signs
traducoes = {
"Aquarius": "Aquário",
"Pisces": "Peixes",
"Aries": "Carneiro",
"Taurus": "Touro",
"Gemini": "Gémeos",
"Cancer": "Caranguejo",
"Leo": "Leão",
"Virgo": "Virgem",
"Libra": "Balança",
"Scorpio": "Escorpião",
"Sagittarius": "Sagitário",
"Capricorn": "Capricórnio"
}
return traducoes.get(signo, signo) but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=calcular_ascendente_signo)
but1.place(relx=0.1, rely=0.7, relwidth=0.25, relheight=0.1) but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.7, relwidth=0.25, relheight=0.1) but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.7, rely=0.7, relwidth=0.25, relheight=0.1) resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3", justify='left')
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9, relheight=0.1) root.mainloop()