Advertisement
Rnery

Imagens no Tkinter

Aug 29th, 2021 (edited)
257
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | Source Code | 1 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import tkinter as tk
  5. from PIL import Image, ImageTk
  6.  
  7. root = tk.Tk()
  8.  
  9. # Criar um objeto com o caminho da imagem
  10. image = Image.open("<path/image_name>")
  11. test = ImageTk.PhotoImage(image)
  12.  
  13. label_image = tk.Label(image=test)
  14. label_image.image = test
  15.  
  16. # Posição da imagem (Coordenadas <X e Y> na Window)
  17. label_image.place(x = '10', y = '10')
  18.  
  19. # Factory Window
  20. root.title('Tkinter Image')
  21. root.resizable(False, False)
  22. root.config(background = 'white')
  23. root.geometry('250x250')
  24. root.eval('tk::PlaceWindow . center')
  25. root.mainloop()
  26.  
Tags: python tkinter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement