estou aprendendo sobre o Tkinter no python e a faculdade me diz esse jeito de inserir uma imagem na janela:
1 from tkinter import *
2
3 def funcClicar():
4 print("Botão pressionado")
5
6 janelaPrincipal = Tk()
7 texto = Label(master = janelaPrincipal, text = "Minha janela exibida")
8 texto.pack()
9
10 pic = PhotoImage(file="logoEstacio.gif")
11 logo = Label(master = janelaPrincipal, image = pic)
12 logo.pack()
13
14 botao = Button(master = janelaPrincipal, text = 'Clique', command = funcClicar)
15 botao.pack()
16
17 janelaPrincipal.mainloop()
18
meu codigo:
import Tkinter
from cgitb import text
from doctest import master
from tkinter import Button, Label, PhotoImage, Tk
from Tkinter import *
def funcClicar():
print("Botao Pressionado!")
janelaPrincipal = Tk()
texto = Label(master = janelaPrincipal, text = "Minha Janela")
texto.place(x = 50, y = 100)
texto.pack
pic = PhotoImage(file="com001.jpg")
python = Label(master= janelaPrincipal, image = pic)
python.pack
botao = Button(master=janelaPrincipal, text="Clique", command= funcClicar)
botao.place(x=60, y=170)
botao.pack
janelaPrincipal.mainloop()
erro no meu codigo: File "C:\Users\Daniel\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 4093, in init Image.init(self, 'photo', name, cnf, master, **kw) File "C:\Users\Daniel\AppData\Local\Programs\Python\Python310\lib\tkinter_init_.py", line 4038, in init self.tk.call(('image', 'create', imgtype, name,) + options) _tkinter.TclError: couldn't open "com001.jpg": no such file or directory PS C:\Users\Daniel\Desktop\programacao>
Obrigado!