Skip to content

Is it possible to insert images to CTkTextbox? #2496

Answered by dipeshSam
Gasiro asked this question in Q&A
Discussion options

You must be logged in to vote

Access internal text box of CTkTextbox. Reason of so is mentioned in the answer of one of the earlier discussion.

Sample code:

from tkinter import *
from customtkinter import CTkTextbox
from PIL.Image import open as open_
from PIL.ImageTk import PhotoImage



if __name__ == "__main__":
	app = Tk()
	
	tb = CTkTextbox(app)
	tb.pack(padx=50, pady=50)
	
	tb.insert("1.0", "Some Text")
	
	tk_img = PhotoImage(open_("theImage.png"))
	
	tb._textbox.image_create("1.1", image=tk_img)


	app.mainloop()

It will be helpful.
Regards.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Gasiro
Comment options

@dipeshSam
Comment options

@Gasiro
Comment options

@dipeshSam
Comment options

Answer selected by Gasiro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants