Advertisement
here2share

# Tk_Jpg2Canvas.py

Jun 14th, 2015
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # Tk_Jpg2Canvas.py
  2.  
  3. import Tkinter as tk
  4. from PIL import ImageTk, Image
  5.  
  6. #This creates the main window of an application
  7. window = tk.Tk()
  8. window.title("JPG to Canvas")
  9. window.geometry("1800x1200")
  10. window.configure(background='grey')
  11.  
  12. directory = 'C:\\Users\\test\\'
  13. filename = "ColorSpectrum.jpg"
  14.  
  15. #Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object.
  16. img = ImageTk.PhotoImage(Image.open(directory+filename))
  17.  
  18. #The Label widget is a standard Tkinter widget used to display a text or image on the screen.
  19. panel = tk.Label(window, image = img)
  20.  
  21. #The Pack geometry manager packs widgets in rows or columns.
  22. panel.pack(side = "bottom", fill = "both", expand = "yes")
  23.  
  24. #Start the GUI
  25. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement