8. Programa de signo zodiacal
El siguiente programa nos permite ingresar una fecha de nacimiento para determinar a que signo zodiacal pertenece.
import sys import Tkinter as tk from Tkinter import * import tkMessageBox ventana = Tk() ventana.title("Signo Zodiacal") ventana.geometry("400x200") ventana.config(bg="black") vp = Frame(ventana) vp.config(bg="pink") vp.grid(column=0, row=0, padx=(50, 50),pady=(10, 10)) # para posicionar cualquier objetovp.columnconfigure(0, weight=1) vp.rowconfigure(0, weight=1) var = StringVar(vp) var.set("Enero") # initial valuever = StringVar(ventana) var1=StringVar(vp) var1.set("1") # initial value etiqueta_mes = Label(vp, text='Mes de nacimiento: ') ent_mes = OptionMenu(vp, var, "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto","Septiembre", "Octubre", "Noviembre", "Diciembre", ) etiqueta_mes.grid(row=1, column=1, padx=(10, 10), pady=(10, 10), sticky=E) ent_mes.grid(row=1, column=3) etiqueta_dia = Label(vp, text='Dia de nacimiento: ') ent_dia = OptionMenu(vp, var1, "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15","16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31") etiqueta_dia.grid(row=4, column=1, padx=(10, 10), pady=(10, 10), sticky=E) ent_dia.grid(row=4, column=3) def signo(): month = str(var.get()) day = int(var1.get()) if month == "Marzo" and day >= 21 or month == "Abril" and day <= 20: tkMessageBox.showinfo("Signo", "Eres Aries") elif month == "Abril" and day >= 21 or month == "Mayo" and day <= 21: tkMessageBox.showinfo("Signo", "Eres Tauro") elif month == "Mayo" and day >= 22 or month == "Junio" and day <= 21: tkMessageBox.showinfo("Signo", "Eres Geminis") elif month == "Junio" and day >= 22 or month == "Julio" and day <= 22: tkMessageBox.showinfo("Signo", "Eres Cancer") if month == "Julio" and day >= 23 or month == "Agosto" and day <= 23: tkMessageBox.showinfo("Signo", "Eres Leo") if month == "Agosto" and day >= 24 or month == "Septiembre" and day <= 23: tkMessageBox.showinfo("Signo", "Eres Virgo") if month == "Septiembre" and day >= 24 or month == "Octubre" and day <= 23: tkMessageBox.showinfo("Signo", "Eres Libra") if month == "Octubre" and day >= 24 or month == "Noviembre" and day <= 22: tkMessageBox.showinfo("Signo", "Eres Escorpion") if month == "Noviembre" and day >= 23 or month == "Diciembre" and day <= 21: tkMessageBox.showinfo("Signo", "Eres Sagitario") if month == "Diciembre" and day >= 22 or month == "Enero" and day <= 20: tkMessageBox.showinfo("Signo", "Eres Capricornio") if month == "Enero" and day >= 21 or month == "Febrero" and day <= 18: tkMessageBox.showinfo("Signo", "Eres Acuario") if month == "Febrero" and day >= 19 or month == "Marzo" and day <= 20: tkMessageBox.showinfo("Signo", "Eres Piscis") boton = Button(vp, text='Signo', command=signo, width=20) boton.grid(row=5, column=1, padx=(10, 10), pady=(10, 10), sticky=E) ventana.mainloop()
Comentarios
Publicar un comentario