CustomTkinter
CustomTkinter copied to clipboard
How to add images in CTkTextBox
@TomSchimansky when I'm trying to add an image in this textbox I get the following kind of error: AttributeError: embedding images is forbidden, because would be incompatible with scaling
You can try this:
import customtkinter
import tkinter as tk
from PIL import ImageTk, Image
app = customtkinter.CTk()
app.title("How to add images in CTkTextBox #2292")
label = tk.Text(app)
label.pack()
image = Image.open("your image path").resize((200, 200))
image = ImageTk.PhotoImage(image)
label.image_create(tk.END, image=image)
app.mainloop()
The issue is image_create
function isn't supported by customtkinter hence describes the reason why you are getting the above code.
Thankx for the info
On Mon, 4 Mar 2024 at 13:02, Ashhad Ahmed @.***> wrote:
You can try this:
import customtkinterimport tkinter as tkfrom PIL import ImageTk, Image app = customtkinter.CTk()app.title("How to add images in CTkTextBox #2292") label = tk.Text(app)label.pack() image = Image.open("your image path").resize((200, 200))image = ImageTk.PhotoImage(image) label.image_create(tk.END, image=image) app.mainloop()
The issue is image_create function isn't supported by customtkinter hence describes the reason why you are getting the above code.
— Reply to this email directly, view it on GitHub https://github.com/TomSchimansky/CustomTkinter/issues/2292#issuecomment-1976200689, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGAIS6IX7D7ZJVWJE763ZCDYWRBCXAVCNFSM6AAAAABEC5HPUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZWGIYDANRYHE . You are receiving this because you authored the thread.Message ID: @.***>
If this answers your question, mark this issue as solved 👍🏻
@AshhadDevLab how do I do that?
Well you should be seeing mark as an answer right below or above the answer I sent to you.