-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTkinter-SearchPokemon.py
More file actions
41 lines (35 loc) · 1.03 KB
/
Tkinter-SearchPokemon.py
File metadata and controls
41 lines (35 loc) · 1.03 KB
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
32
33
34
35
36
37
38
39
40
41
import tkinter as tk
from tkinter import messagebox
# Arreglo de Pokémon
pokemons = {
"Bulbasaur": "Planta",
"Charmander": "Fuego",
"Squirtle": "Agua",
"Pikachu": "Eléctrico",
"Jigglypuff": "Normal",
"Eevee": "Normal",
"Snorlax": "Normal",
"Mewtwo": "Psíquico",
"Gengar": "Fantasma",
"Dragonite": "Dragón"
}
def buscar_pokemon():
nombre = entry.get()
if nombre in pokemons:
tipo = pokemons[nombre]
messagebox.showinfo("Resultado", f"{nombre} es de tipo {tipo}.")
else:
messagebox.showerror("Error", f"No se encontró el Pokémon {nombre}.")
# Configuración de la ventana
ventana = tk.Tk()
ventana.title("Buscar Pokémon")
# Etiqueta y entrada para ingresar el nombre del Pokémon
label = tk.Label(ventana, text="Nombre del Pokémon:")
label.pack(pady=10)
entry = tk.Entry(ventana)
entry.pack()
# Botón para buscar el Pokémon
boton_buscar = tk.Button(ventana, text="Buscar", command=buscar_pokemon)
boton_buscar.pack(pady=5)
# Ejecutar la ventana
ventana.mainloop()