Mundo em Python

Pokédex

from tkinter import *

# ===================== DADOS =====================
pokemon_150 = {
1: {"nome": "Bulbasaur", "tipo": ["Planta", "Veneno"], "proxima_evolucao": "Ivysaur"},
2: {"nome": "Ivysaur", "tipo": ["Planta", "Veneno"], "proxima_evolucao": "Venusaur"},
3: {"nome": "Venusaur", "tipo": ["Planta", "Veneno"], "proxima_evolucao": None},
4: {"nome": "Charmander", "tipo": ["Fogo"], "proxima_evolucao": "Charmeleon"},
5: {"nome": "Charmeleon", "tipo": ["Fogo"], "proxima_evolucao": "Charizard"},
6: {"nome": "Charizard", "tipo": ["Fogo", "Voador"], "proxima_evolucao": None},
7: {"nome": "Squirtle", "tipo": ["Água"], "proxima_evolucao": "Wartortle"},
8: {"nome": "Wartortle", "tipo": ["Água"], "proxima_evolucao": "Blastoise"},
9: {"nome": "Blastoise", "tipo": ["Água"], "proxima_evolucao": None},
10: {"nome": "Caterpie", "tipo": ["Inseto"], "proxima_evolucao": "Metapod"},
11: {"nome": "Metapod", "tipo": ["Inseto"], "proxima_evolucao": "Butterfree"},
12: {"nome": "Butterfree", "tipo": ["Inseto", "Voador"], "proxima_evolucao": None},
13: {"nome": "Weedle", "tipo": ["Inseto", "Veneno"], "proxima_evolucao": "Kakuna"},
14: {"nome": "Kakuna", "tipo": ["Inseto", "Veneno"], "proxima_evolucao": "Beedrill"},
15: {"nome": "Beedrill", "tipo": ["Inseto", "Veneno"], "proxima_evolucao": None},
16: {"nome": "Pidgey", "tipo": ["Normal", "Voador"], "proxima_evolucao": "Pidgeotto"},
17: {"nome": "Pidgeotto", "tipo": ["Normal", "Voador"], "proxima_evolucao": "Pidgeot"},
18: {"nome": "Pidgeot", "tipo": ["Normal", "Voador"], "proxima_evolucao": None},
19: {"nome": "Rattata", "tipo": ["Normal"], "proxima_evolucao": "Raticate"},
20: {"nome": "Raticate", "tipo": ["Normal"], "proxima_evolucao": None},
25: {"nome": "Pikachu", "tipo": ["Eléctrico"], "proxima_evolucao": "Raichu"},
26: {"nome": "Raichu", "tipo": ["Eléctrico"], "proxima_evolucao": None},
150: {"nome": "Mewtwo", "tipo": ["Psíquico"], "proxima_evolucao": None}
} # ===================== JANELA =====================
root = Tk()
root.geometry("700x400")
root.resizable(False, False)
root.config(bg="#103030")
root.title("Pokédex") # ===================== TÍTULO =====================
Label(
root,
text="Pokédex",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
).place(relx=0.4, rely=0.05) # ===================== FUNÇÃO =====================
def mostrar_pokemon():
valor = entrada.get().strip().lower()
pokemon = None

if valor.isdigit():
pokemon = pokemon_150.get(int(valor))
else:
for p in pokemon_150.values():
if p["nome"].lower() == valor:
pokemon = p
break

if pokemon:
nome_lbl.config(text=f"Nome: {pokemon['nome']}")
tipo_lbl.config(text=f"Tipo: {', '.join(pokemon['tipo'])}")
evo_lbl.config(
text=f"Próxima evolução: {pokemon['proxima_evolucao'] or 'Nenhuma'}"
)
else:
nome_lbl.config(text="Pokémon não encontrado")
tipo_lbl.config(text="")
evo_lbl.config(text="") # ===================== ENTRADA =====================
Label(
root,
text="Número ou Nome do Pokémon:",
bg="#103030",
fg="white",
font=("Arial", 12)
).place(x=40, y=120) entrada = Entry(root, font=("Arial", 12), width=20)
entrada.place(x=280, y=120) Button(
root,
text="Pesquisar",
font=("Arial", 12),
command=mostrar_pokemon
).place(x=500, y=115) # ===================== RESULTADOS =====================
nome_lbl = Label(root, bg="#103030", fg="#49e3e3", font=("Arial", 14))
nome_lbl.place(x=40, y=190) tipo_lbl = Label(root, bg="#103030", fg="#49e3e3", font=("Arial", 14))
tipo_lbl.place(x=40, y=230) evo_lbl = Label(root, bg="#103030", fg="#49e3e3", font=("Arial", 14))
evo_lbl.place(x=40, y=270) # ===================== LOOP =====================
root.mainloop()
0