Skip to content

Instantly share code, notes, and snippets.

@Alkz6
Created June 6, 2018 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alkz6/913fa7044e3604c6e62b695b1ffdeed9 to your computer and use it in GitHub Desktop.
Save Alkz6/913fa7044e3604c6e62b695b1ffdeed9 to your computer and use it in GitHub Desktop.
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