我的数据库包含一个名为 LOGO 的图像(BLOB)。我想在 python TkInter 窗口上显示图像
import Tkinter
window= Tk()
db= MySQLdb.connect("localhost","root","anup","NursecallDB")
cursor=db.cursor()
sql= "SELECT LOGO FROM SYSTEMDETAILS"
cursor.execute(sql)
logo=cursor.fetchone()
img =PhotoImage(logo)
panel = Tkinter.Label(window, image = img)
panel.grid(row=0,rowspan=5,columnspan=2)
window.mainloop()
当我运行这个程序时,它显示错误
panel = Tkinter.Label(window, image = img)
TypeError:_str_returned non-string(type tuple)
最佳答案
将图像上传到文件夹并将路径插入数据库。如果logo是图片的路径。然后程序就可以工作了。
关于mysql - 将 mysql 数据库中的图像(BLOB)显示到 tkinter 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29407479/