![]() ![]() While True: # Add frames until out of rangeįrames.append(PhotoImage(file='test.gif',format = 'gif -index %i' %(i)))ĭef update(ind): # Display and loop the GIF Print("Exception when calling DefaultApi->gifs_search_get: %s\n" % e) Response = api_instance.gifs_search_get(api_key,query,limit=1,offset=randint(1,10),fmt=fmt) Install Tkinter if isn't included with your Python installation.įrom giphy_client.rest import ApiException For this case, I will use the example posted here, with a few modifications,to display the Gif using TKinter. You need to investigate which GUI adapts better to your needs. There are a bunch of GUIs for Python to do this, or you can even invoke a browser to show it. Seems that you already tried to do this, but with an error. I will use the requests library to do this, install it with pip if you don't have in your environment. Now that you have a URL, it's time to download the GIF. So, I will add this to your code: gif_url = gif_id. ![]() You can see all the elements retrieved using print(gif_id) In this case, I went with the downsized GIF. ![]() The Gif object you got, called gif_id, has a bunch of URLs to download the GIF or MP4 at different resolutions. Note that when I print this, I get an URL. That giphy_client client you are using, is made with Swagger, so, you can access the REST Response elements like any other object, or print them.įor example: > print(gif_id.) There are 3 steps needed to get the image: I see your code does successfully retrieve a random image, that is good. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |