473,288 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

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

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.com/charts/metals/gold/t24_au_en_eukg_2.gif
Its a chart of the value of gold in the last 24 hours....
Oct 17 '07 #1
2 1640
ilikepython
844 Expert 512MB
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.com/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:
Expand|Select|Wrap|Line Numbers
  1. import urllib
  2.  
  3. pg = urllib.urlopen("http://www.kitconet.com/charts/metals/gold/t24_au_en_eukg_2.gif")
  4. data = pg.read()
  5.  
  6. f = open("myGoldPic.gif", "wb")
  7. f.write(data)
  8. f.close()
  9.  
And then you can use myGoldPic.gif as your image file.
Oct 20 '07 #2
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!!!!
Oct 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Jay O'Connor | last post by:
Is there a good way to import python files without executing their content? I'm trying some relfection based stuff and I want to be able to import a module dynamically to check it's contents...
4
by: Kersten | last post by:
Hi to all, I havea big DB with information and pictures of our employees and this DB is used by a lot of people in our company. The data format is Access2000. In the past the import of pictures...
1
by: slomo | last post by:
I'm working on linux Fedora Core 3 with Python 2.3. I can't "from Tkinter import *" . And see only "No modlue named Tkiner" error. Of course I have tk/tcl 8.4. They works perfectly. Certainly, I...
8
by: John Salerno | last post by:
Hi all. Quick question (but aren't they all?) :) Do you think it's a good idea to use the 'from <name> import *' statement when using a GUI module? It seems on wxPython's site, they recommend...
5
by: W. Watson | last post by:
Is there a single source that explains these statements? ------------------------------ from Tkinter import * from Numeric import * import Image import ImageChops import ImageTk import time...
3
by: notnorwegian | last post by:
import Tkinter from Tkinter import * i have a program where if i comment out either of those import- statements i get an error. i thought they meant the same thing and from was supposed to be...
5
by: Alexnb | last post by:
Hello I am sure most of you are familiar with py2exe. I am having a bit of a problem. See the program has a few pictures involved and the .ico it uses for the windows. However, the pictures are...
1
by: Pierre Dagenais | last post by:
from Tkinter import * win = Tk() If I type those two lines at the command prompt (in WindowsXP) I get a new window on my screen. Yet if I copy those lines in a file called test.py and then...
5
by: Reckoner | last post by:
I have multiple packages that have many of the same function names. Is it possible to do from package1 import * from package2 import * without overwriting similarly named objects from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.