您能从pyimg获取文件名吗

2024-10-02 10:21:05 发布

您现在位置:Python中文网/ 问答频道 /正文

from PIL import Image as PILImage
Rewind_Normal = PhotoImage(file="Rewind_Normal.png")
RewindButton = Button(root, image = Rewind_Normal)
myimage = RewindButton.cget("image") // returns "pyimage0"

有没有办法从这个字符串中获取原始文件名? python或Tkinter似乎对图像使用了一个参考系统(基于cget返回的字符串)。我可以使用此引用检索图像的实际文件名吗

大概是这样的:

for item in pyimageList
    if item.name == myimage
     // do other things

Tags: 字符串from图像imageimportpil文件名as

热门问题