Skip to content

How to render images? #562

Answered by Akascape
Jeymen asked this question in Q&A
Oct 26, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

@Jeymen

import os

image_label = customtkinter.CTkButton(app, text = "", fg_color=None, hover=False) # Your image widget
image_label.grid()

name = "image.png" # file name
if os.path.exists(name): 
    # If the file exists then render it in the widget
    image_label.configure(image = ImageTk.PhotoImage(Image.open(name).resize((200, 200), Image.Resampling.LANCZOS)))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Jeymen
Comment options

Answer selected by Jeymen
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