Mundo em Python

Jogo das Ilhas dos Açores

from tkinter import *
root = Tk()
root.geometry("550x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Jogo das Ilhas dos Açores") ilhas_acores = [
"São Miguel", "Terceira", "Pico", "Faial", "Santa Maria",
"São Jorge", "Graciosa", "Flores", "Corvo"
]
ilhas_acores = [ilha.lower() for ilha in ilhas_acores]
acertadas = []
titulo = Label(text="Jogo das Ilhas dos Açores",
font=("Arial", "28", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05) texto_sub1 = Label(text="Digite uma Ilha:",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.05, rely=0.32)
resposta = StringVar()
resposta_entrada = Entry(textvariable=resposta,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
resposta_entrada.place(relx=0.5, rely=0.33, relwidth=0.4) def app(event=None):
tentativa = resposta.get().strip().lower()
if tentativa == "sair":
resultado_texto.config(text="Obrigado por jogar! Até a próxima!", bg="#cfe2f3")
return
if tentativa in ilhas_acores:
if tentativa not in acertadas:
acertadas.append(tentativa)
faltam = 9 - len(acertadas)
resultado_texto.config(
text=f"Boa! Você acertou: {tentativa.title()}\nFaltam {faltam} ilhas para acertar.",
bg="#d9ead3"
)
else:
resultado_texto.config(
text="Você já adivinhou essa ilha! Tente outra.",
bg="#fce5cd"
)
else:
resultado_texto.config(
text="Essa não é uma das ilhas dos Açores. Tente novamente!",
bg="#f4cccc"
)
if len(acertadas) == 9:
resultado_texto.config(
text="Parabéns! Você acertou todas as 9 ilhas dos Açores!",
bg="#d9ead3"
)
resposta.set("") def limpar():
mensagem = "São Miguel, Terceira, Pico, Faial,\n Santa Maria, São Jorge, Graciosa, Flores e Corvo"
resultado_texto.config(text=mensagem, bg="#d9ead3", fg="black") but1 = Button(text="Submeter", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.45, relwidth=0.25, relheight=0.1) but_limpar = Button(text="Todas as ilhas", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.4, rely=0.45, 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.45, relwidth=0.25, relheight=0.1)
resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#103030", fg="black", justify="center")
resultado_texto.place(relx=0.05, rely=0.6, relwidth=0.9, relheight=0.25)
resposta_entrada.bind("<Return>", app) root.mainloop()
0