This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from Tkinter import * | |
def seleccionar(): | |
cadena = "" | |
if (leche.get()): | |
cadena += "Con leche" | |
else: | |
cadena += "Sin leche" | |
if (azucar.get()): | |
cadena += " y con azúcar" | |
else: | |
cadena += " y sin azúcar" | |
monitor.config(text=cadena) | |
# Configuración de la raíz | |
root = Tk() | |
root.title("Cafetería") | |
root.config(bd=15) | |
leche = IntVar() # 1 si, 0 no | |
azucar = IntVar() # 1 si, 0 no | |
imagen = PhotoImage(file="image.gif") | |
Label(root, image=imagen).pack(side="left") | |
frame = Frame(root) | |
frame.pack(side="left") | |
Label(frame, text="¿Cómo quieres el café?").pack(anchor="w") | |
Checkbutton(frame, text="Con leche", variable=leche, onvalue=1, | |
offvalue=0, command=seleccionar).pack(anchor="w") | |
Checkbutton(frame, text="Con azúcar", variable=azucar, onvalue=1, | |
offvalue=0, command=seleccionar).pack(anchor="w") | |
monitor = Label(frame) | |
monitor.pack() | |
# Finalmente bucle de la aplicación | |
root.mainloop() |
No hay comentarios:
Publicar un comentario