Python 无法使用PhotoImage读取base 64字符串
我试图通过从另一个文件Python 无法使用PhotoImage读取base 64字符串,python,tkinter,Python,Tkinter,我试图通过从另一个文件background\u image.py读取一个base 64字符串,将背景图像直接绘制到画布背景中。根据规定,这些线路应能正常工作: import background_image background_image = ImageTk.PhotoImage(data=background_image.background_image) canvas.create_image(0, 0, image=background_image, anchor=NW) 但我得
background\u image.py
读取一个base 64字符串,将背景图像直接绘制到画布背景中。根据规定,这些线路应能正常工作:
import background_image
background_image = ImageTk.PhotoImage(data=background_image.background_image)
canvas.create_image(0, 0, image=background_image, anchor=NW)
但我得到了这个错误:
Traceback (most recent call last):
File "c:\Python34\lib\site-packages\PIL\ImageTk.py", line 118, in __del__
name = self.__photo.name
AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
导入的变量
background\u image
指的是什么?导入一个值,然后将其他内容重新指定给该名称,这不是一种好做法。这使得代码更难理解和调试。