Я хочу знать, как добавить текст к изображению в tkinter. Я набираю следующий код:
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
draw=ImageDraw.Draw("maybe.png")
pixellat=ImageFont.truetype("pixellat.ttf",18)
draw.text((125, 125),"This is a test",(255,255,255),font=pixellat)
Но я получаю эту ошибку:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-
packages/PIL/ImageDraw.py", line 344, in Draw
return im.getdraw(mode)
AttributeError: 'str' object has no attribute 'getdraw'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Apple/Desktop/pong 1.2/pong menu.py", line 41, in <module>
draw=ImageDraw.Draw("maybe.png")
File "/usr/local/lib/python3.7/site-
packages/PIL/ImageDraw.py", line 346, in Draw
return ImageDraw(im, mode)
File "/usr/local/lib/python3.7/site-packages/PIL/ImageDraw.py", line 60, in __init__
im.load()
AttributeError: 'str' object has no attribute 'load'
Можете ли вы помочь мне исправить это? Спасибо.