Created
June 6, 2018 02:24
-
-
Save Alkz6/913fa7044e3604c6e62b695b1ffdeed9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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