Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_img_transparency.py
- from Tkinter import Tk, Frame, Canvas
- from PIL import Image,ImageTk
- import urllib2
- import sys
- import base64
- t = Tk()
- t.title("Transparency")
- frame = Frame(t)
- frame.pack()
- canvas = Canvas(frame, bg="gray", width=400, height=400)
- canvas.pack()
- try:
- photoimage1 = ImageTk.PhotoImage(file="solidball.png")
- photoimage2 = ImageTk.PhotoImage(file="example.png")
- except:
- def oURL(dd):
- URL = 'http://tinyurl.com/h2sball00'+str(dd)
- u = urllib2.urlopen(URL)
- raw_data = u.read()
- u.close()
- b64_data = base64.encodestring(raw_data)
- return PhotoImage(data=b64_data)
- photoimage1 = oURL(1)
- photoimage2 = oURL(2)
- photoimage1.save()
- photoimage2.save()
- #
- canvas.create_image(150, 150, image=photoimage1)
- canvas.create_image(250, 250, image=photoimage2)
- t.mainloop()
Add Comment
Please, Sign In to add comment