Skip to content

Instantly share code, notes, and snippets.

@Alkz6 Alkz6/findpoke.py

Created Jun 6, 2018
Embed
What would you like to do?
from guizero import App, TextBox, PushButton, Picture, Text, warn
from pokebase import pokemon
from requests import get
from PIL import Image
from io import BytesIO
def fetch_pokemon():
name = input_box.value
try:
poke = pokemon(name)
weight_text.value = "Height: " + str(poke.weight)
height_text.value = "Height: " + str(poke.height)
pic = get(poke.sprites.front_default).content
image = Image.open(BytesIO(pic))
image.save('poke.gif')
icon.value = 'poke.gif'
except:
warn("404 - Not Found", "Pokemon not found - please select another one")
app = App(title='Pokemon Fetcher', width=300, height=200)
input_box = TextBox(app, text='Name')
icon = Picture(app, image="poke.gif")
weight_text = Text(app, text='')
height_text = Text(app, text='')
submit = PushButton(app, command=fetch_pokemon, text='Submit')
app.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.