Mundo em Python

Brincar com Radiobutton e Checkbutton (Pedido à cozinha)

from tkinter import *
root = Tk()
root.geometry("600x300")
root.resizable(0, 0)
root.title("Escolha de Refeição")
root.config(bg="#d9ead3") def option():
selection = "O seu pedido é " + str(carne.get())
label.config(text = selection) def seleccionar():
texto = ""
if (arroz.get()):
texto += " Com Arroz "
else:
texto += " "

if (massa.get()):
texto += " Com Massa "
else:
texto += " "
if (salada.get()):
texto += " Com Salada "
else:
texto += " "
if (batatafrita.get()):
texto += " Com Batatas Fritas "
else:
texto += " "

monitor.config(text=texto) carne = StringVar()
bife = Radiobutton(root,text="Bife", value="Bife", variable=carne,
command=option,font=("Arial","12","bold"),fg="#ce7e00", bg="#d9ead3")
bife.place(relx=0.05,rely=0.3) lombo = Radiobutton(root,text="Lombo", value="Lombo", variable=carne,
command=option,font=("Arial","12","bold"),fg="#ce7e00", bg="#d9ead3")
lombo.place(relx=0.05,rely=0.5) texto1 =Label(root, text="Proteínas",font=("Arial","14","bold"), bg="#d9ead3",fg="#bf9000")
texto1.place(relx=0.05,rely=0.1) # Acompanhament
texto2 =Label(root, text="Acompanhamento",font=("Arial","14","bold"), bg="#d9ead3",fg="#bf9000")
texto2.place(relx=0.6,rely=0.1)
arroz =IntVar()
batatafrita =IntVar()
massa =IntVar()
salada =IntVar() a1=Checkbutton(text="Arroz", variable=arroz, onvalue=1,
offvalue=0, command=seleccionar,font=("Arial", "12", "bold")
,bg="#d9ead3",fg="#bf9000").place(relx=0.5, rely=0.3)
a2=Checkbutton( text="Batata Frita", variable=batatafrita, onvalue=1,
offvalue=0, command=seleccionar,font=("Arial", "12", "bold")
,bg="#d9ead3",fg="#bf9000").place(relx=0.5, rely=0.45) a3=Checkbutton(text="Massa", variable=massa, onvalue=1,
offvalue=0, command=seleccionar,font=("Arial", "12", "bold")
,bg="#d9ead3",fg="#bf9000").place(relx=0.75, rely=0.3)
a4=Checkbutton( text="Salada", variable=salada, onvalue=1,
offvalue=0, command=seleccionar,font=("Arial", "12", "bold")
,bg="#d9ead3",fg="#bf9000").place(relx=0.75, rely=0.45)
label = Label(root,font=("Arial","12","bold"),fg="blue", bg="#d9ead3")
label.place(relx=0.35,rely=0.65)
monitor = Label(bg="#d9ead3",font=("Arial", "12", "bold"),fg="blue")
monitor.place(relx=0.1, rely=0.75)
root.mainloop()
0