Python Forum
howto get size of a ctk image?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
howto get size of a ctk image?
#1
hi, I have a CTkImage that needs heigth and width size of image.
Guess I have to use cget but doesnt find parameters.
my_image.cget(?,?)
Anyone?

my_image = customtkinter.CTkImage(light_image=Image.open(var1),size=(h, w))
    image_label = customtkinter.CTkLabel(window, image=my_image, text="")
Reply
#2
"size". my_image.cget("size") returns the size attribute (width, height) of one of the images. The light and dark images have to be the same size, so it doesn't matter which.

You could also ask for one of the images and then ask it for the size.
image.cget("light_image").size
That is how you know to use "size" as the attribute for cget. PIL.Image.size returns the size of the image. CTkImage.cget("size") returns the size attribute of the light or dark image.
janeik likes this post
Reply
#3
(Oct-03-2023, 03:33 AM)deanhystad Wrote: "size". my_image.cget("size") returns the size attribute (width, height) of one of the images. The light and dark images have to be the same size, so it doesn't matter which.

You could also ask for one of the images and then ask it for the size.
image.cget("light_image").size
That is how you know to use "size" as the attribute for cget. PIL.Image.size returns the size of the image. CTkImage.cget("size") returns the size attribute of the light or dark image.
Thank You. I missed the mention in documentation that images are PIL objects at first read.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Howto do motion event on solely window and not the widgets on it? janeik 3 861 Jul-11-2023, 12:10 AM
Last Post: deanhystad
  PIL doesn't seem to paste full size image. DreamingInsanity 7 3,339 Nov-21-2019, 07:42 PM
Last Post: DreamingInsanity
  size of set vs size of dict zweb 0 2,152 Oct-11-2019, 01:32 AM
Last Post: zweb
  Is there a way to detect the text font, size and color from an image in python? Maia07 2 8,690 Aug-23-2018, 01:16 PM
Last Post: Maia07
  CSV file created is huge in size. How to reduce the size? pramoddsrb 0 10,494 Apr-26-2018, 12:38 AM
Last Post: pramoddsrb
  Howto try catch consuli 2 3,905 Nov-14-2016, 08:03 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020