El siguiente programa determina tu signo zodiacal dependiendo de la fecha de nacimiento, obtenida mediante 2 entry de tipo optionmenu(menú de opciones) lista desplegable para algunos, le pones esas 2 entradas y al picar al botón de calcular te muestra en un mensajebox el resultado(el signo zodiacal).
       


       # -*- coding: utf-8 -*-

import sys
import Tkinter as tk
from Tkinter import *
import tkMessageBox

ventana = Tk()
ventana.title("Signo Zodiacal")
ventana.geometry("500x300")
ventana.config(bg="aquamarine")

vp = Frame(ventana)
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='Día 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("Tu Signo", "Eres Aries")
    elif month == "Abril" and day >= 21 or month == "Mayo" and day <= 21:
        tkMessageBox.showinfo("Tu Signo", "Eres Tauro")
    elif month == "Mayo" and day >= 22 or month == "Junio" and day <= 21:
        tkMessageBox.showinfo("Tu Signo", "Eres Gemenis")
    elif month == "Junio" and day >= 22 or month == "Julio" and day <= 22:
        tkMessageBox.showinfo("Tu Signo", "Eres Cancer")
    elif month == "Julio" and day >= 23 or month == "Agosto" and day <= 23:
        tkMessageBox.showinfo("Tu Signo", "Eres Leo")
    elif month == "Agosto" and day >= 24 or month == "Septiembre" and day <= 23:
        tkMessageBox.showinfo("Tu Signo", "Eres Virgo")
    elif month == "Septiembre" and day >= 24 or month == "Octubre" and day <= 23:
        tkMessageBox.showinfo("Tu Signo", "Eres Libra")
    elif month == "Octubre" and day >= 24 or month == "Noviembre" and day <= 22:
        tkMessageBox.showinfo("Tu Signo", "Eres Escorpion")
    elif month == "Noviembre" and day >= 23 or month == "Diciembre" and day <= 21:
        tkMessageBox.showinfo("Tu Signo", "Eres Sagitario")
    elif month == "Diciembre" and day >= 22 or month == "Enero" and day <= 20:
        tkMessageBox.showinfo("Tu Signo", "Eres Capricornio")
    elif month == "Enero" and day >= 21 or month == "Febrero" and day <= 18:
        tkMessageBox.showinfo("Tu Signo", "Eres Acuario")
    elif month == "Febrero" and day >= 19 or month == "Marzo" and day <= 20:
        tkMessageBox.showinfo("Tu Signo", "Eres Piscis")


boton = Button(vp, text='Determinar el Signo Zodiacal', command=signo, width=25)
boton.grid(row=5, column=1, padx=(10, 10), pady=(10, 10), sticky=E)

ventana.mainloop()

La corrida quedaría mas o menos así:

Comentarios

Entradas populares de este blog

Registros del lenguaje ensamblador

Ventajas y desventajas de lenguaje ensamblador

Unidad 4 Administración de Base de Datos