We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying , like this :
from tkinter import * from io import BytesIO window= Tk() db=MySQLdb.connect("localhost","root","??","??") cursor=db.cursor() sql= "SELECT LOGO FROM SYSTEMDETAILS" cursor.execute(sql) logo=cursor.fetchone() img = Image.open(BytesIO(logo)) phimg = ImageTk.PhotoImage(img) panel = Label(window, image = phimg) panel.pack()
When i run this, it show error in line 9 , it want logo as an object but in here its tuple
The text was updated successfully, but these errors were encountered:
Hello @2020Yasir-Sahibzada,
I think you can try to access like this,
logo = cursor.fetchone() img_data = logo[0]
And after that you can use the BytesIO class to wrap the image data,
img = Image.open(BytesIO(img_data))
Sorry, something went wrong.
Hey @2020Yasir-Sahibzada I think you didn't included mysql imports for the code adding them might solve your issue
import mysql.connector from tkinter import Tk, Label from PIL import Image, ImageTk from io import BytesIO
conn = mysql.connector.connect(user='username', password='password', host='localhost', database='your_db') cursor = conn.cursor()
cursor.execute("SELECT image_column FROM images_table WHERE id = %s", (image_id,)) logo = cursor.fetchone()
img_data = logo[0] img = Image.open(BytesIO(img_data))
root = Tk() tk_img = ImageTk.PhotoImage(img) label = Label(root, image=tk_img) label.pack()
root.mainloop() Insert image pip install mysql-connector-python pillow Bash
No branches or pull requests
I am trying , like this :
from tkinter import *
from io import BytesIO
window= Tk()
db=MySQLdb.connect("localhost","root","??","??")
cursor=db.cursor()
sql= "SELECT LOGO FROM SYSTEMDETAILS" cursor.execute(sql)
logo=cursor.fetchone()
img = Image.open(BytesIO(logo))
phimg = ImageTk.PhotoImage(img)
panel = Label(window, image = phimg)
panel.pack()
When i run this, it show error in line 9 , it want logo as an object but in here its tuple
The text was updated successfully, but these errors were encountered: