LINK: DESCARGAR CÓDIGO
| EJECUCIÓN DE PROGRAMA |
import base64
try:
# Python2
import Tkinter as tk
from urllib2 import urlopen
except ImportError:
# Python3
import tkinter as tk
from urllib.request import urlopen
root = tk.Tk()
root.title("Implementar imagenes de web")
# margenes
w = 520
h = 320
x = 80
y = 100
# usar width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
# cualquier imagen de la red
image_url = "https://eltallerdelaserenidad.files.wordpress.com/2016/05/loto-movimiento.gif?w=640"
image_byt = urlopen(image_url).read()
image_b64 = base64.encodestring(image_byt)
photo = tk.PhotoImage(data=image_b64)
# SE CREA UN CANVAS BLANCO
cv = tk.Canvas(bg='white')
cv.pack(side='top', fill='both', expand='yes')
# SE COLOCA LA IMAGEN EN EL CANVAS
# CREAR_IMAGEN(xpos, ypos, image, anchor)
cv.create_image(10, 10, image=photo, anchor='nw')
root.mainloop()
No hay comentarios:
Publicar un comentario