Вот код:
from tkinter import *
from PIL import Image, ImageTk
count = 0
def hide():
if button_hide['state'] == 'normal':
input_password['show'] = ''
button_hide['image'] = img_photo2
global count
print(count)
count += 1
if count % 2 == 0:
input_password['show'] = '*'
button_hide['image'] = img_photo
window = Tk()
window.geometry("700x300+480+200")
window.title("VK")
img_photo = ImageTk.PhotoImage(Image.open('picture.png'))
img_photo2 = ImageTk.PhotoImage(Image.open('picture2.png'))
button_hide = Button(image = img_photo, command=hide)
button_hide.place(x=300, y=60)
window.mainloop()
Ошибка:
Traceback (most recent call last):
File "C:\Users\Уваж Руслан Рафэкови\PycharmProjects\pythonProject\Tests\test2.py", line 21, in <module>
img_photo = ImageTk.PhotoImage(Image.open('picture.png'))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Уваж Руслан Рафэкови\PycharmProjects\pythonProject\venv\Lib\site-packages\PIL\Image.py", line 3277, in open
fp = builtins.open(filename, "rb")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Уваж Руслан Рафэкови\\PycharmProjects\\pythonProject\\Tests\\picture.png'