CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

How to add images in CTkTextBox

Open Joshrocky opened this issue 1 year ago • 6 comments

@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

Joshrocky avatar Mar 02 '24 08:03 Joshrocky

Uploading Capture.PNG…

Joshrocky avatar Mar 02 '24 08:03 Joshrocky

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.

AshhadDevLab avatar Mar 04 '24 10:03 AshhadDevLab

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: @.***>

Joshrocky avatar Mar 04 '24 11:03 Joshrocky

If this answers your question, mark this issue as solved 👍🏻

AshhadDevLab avatar Mar 04 '24 12:03 AshhadDevLab

@AshhadDevLab how do I do that?

Joshrocky avatar Mar 05 '24 05:03 Joshrocky

Well you should be seeing mark as an answer right below or above the answer I sent to you.

AshhadDevLab avatar Mar 05 '24 06:03 AshhadDevLab