How do I import image into Python with the Tkinter GUI? [closed]

0

Can you put image in the tkinter library widget?

    
asked by anonymous 06.06.2017 / 02:21

1 answer

2

The 'hello world' image in tkinter is something like the following code:

import tkinter as tk
root = tk.Tk()

imagem = tk.PhotoImage(file="stack-overflow.png")
w = tk.Label(root, image=imagem)
w.imagem = imagem
w.pack()

root.mainloop()

Result:

P.S.AcompletepathtotheimageinWindowswouldlooksomethinglikethis:

imagem=tk.PhotoImage(file="c:/Users/Public/Pictures/stack-overflow.png")
    
06.06.2017 / 03:29