bobhig

pokemonfetch2

May 28th, 2021 (edited)
201
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from guizero import App, Text, TextBox, PushButton, Picture
  2. from pokebase import pokemon
  3. import webbrowser
  4. from requests import get
  5. from PIL import Image
  6. from io import BytesIO
  7.  
  8. app = App(title='Pokemon Fetcher', width=500, height=500)
  9.  
  10. weightdisplay = "test"
  11.  
  12. print(weightdisplay)
  13.  
  14. welcome = Text(app, text="Which Pokemon do you want to fetch?")
  15.  
  16. def fetch_pokemon():
  17.     global weightdisplay
  18.     name = input_box.value
  19.     poke = pokemon(name)
  20.     pic = get(poke.sprites.front_default).content
  21.     image = Image.open(BytesIO(pic))
  22.     image.save('poke.gif')
  23.     icon.value = 'poke.gif'
  24.     weight = Text(app, str(poke.weight) + " Weight")
  25.     weightdisplay = poke.weight
  26.     print(weightdisplay)
  27.     height = Text(app, str(poke.height) + " Height")
  28.  
  29. input_box = TextBox(app)
  30. submit = PushButton(app, text='Fetch', command=fetch_pokemon)
  31. icon = Picture(app, image="poke.gif")
  32.  
  33. app.display()
  34. print(weightdisplay)
RAW Paste Data