How can i import pictures from a web page to my Tkinter GUI?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Elias Alhanatis
    New Member
    • Aug 2007
    • 56

    How can i import pictures from a web page to my Tkinter GUI?

    Hello everybody!!!

    I need some help with the following task:
    I want to embed an image(gif) from a web page ( which is dynamicaly updated in that page which means i cannot download it just once...), in my GUI. I need this to happen only when a user "starts" my program .
    So , how can i "get" the image from the web page and have it as an object in my program?
    I am working on Windows Vista , Python 2.5.

    Thank you all in advance!!!!!!

    P.S.: In order to be more precice , the image i want is this:
    http://www.kitconet.co m/charts/metals/gold/t24_au_en_eukg_ 2.gif
    Its a chart of the value of gold in the last 24 hours....
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #2
    Originally posted by Elias Alhanatis
    Hello everybody!!!

    I need some help with the following task:
    I want to embed an image(gif) from a web page ( which is dynamicaly updated in that page which means i cannot download it just once...), in my GUI. I need this to happen only when a user "starts" my program .
    So , how can i "get" the image from the web page and have it as an object in my program?
    I am working on Windows Vista , Python 2.5.

    Thank you all in advance!!!!!!

    P.S.: In order to be more precice , the image i want is this:
    http://www.kitconet.co m/charts/metals/gold/t24_au_en_eukg_ 2.gif
    Its a chart of the value of gold in the last 24 hours....
    You could do something like this:
    [code=python]
    import urllib

    pg = urllib.urlopen( "http://www.kitconet.co m/charts/metals/gold/t24_au_en_eukg_ 2.gif")
    data = pg.read()

    f = open("myGoldPic .gif", "wb")
    f.write(data)
    f.close()
    [/code]
    And then you can use myGoldPic.gif as your image file.

    Comment

    • Elias Alhanatis
      New Member
      • Aug 2007
      • 56

      #3
      That in deed does the job!!!!
      Thank you so much!!!
      ( I went through almost all the Python tutorials i have and didn't find any piece
      of code as simple as that.... and also i think that now i can understand the
      mechanism used for downloading through Python). Thanks again!!!!

      Comment

      Working...