r/PythonLearning • u/Somewhat_AL1VE • 18h ago
Help Request How to handle dynamic image/text scaling across multiple pages in CustomTkinter?
Hi everyone,
I'm building a multi-page CustomTkinter desktop app where I swap pages inside a main container. I want my text and CTkImage sizes to automatically adjust whenever the user resizes the main window. So far, my widgets automatically adjust because I use .place() with relative sizes and placements. But even if the widget itself grows, the text/image stays the same size, which doesn't look appealing in the slightest.
Basic info:
ghost_pic is the label that houses my CTkImage; this automatically changes size already.
ghost_mid_image is the CTkImage
First try:
I thought that I could try to make the image change its size to match its label every time the window changed size. This is because I made sure that the image is approximately the same size as the label on the default window size, but this didn't do anything; the code didn't work at all.
Second try:
I then decided to just size the image with reference to the window, and this kinda worked? When I go to the page that houses this image and resize my window, it works ( very sloppily, but that's an issue for another day). My problem now is that if I enter that page, say, on full screen, the image just goes haywire; sometimes it's too small or too big. I don't know what to do now. I uploaded my indicator function, which is how I change the page; if there is a problem there, let me know.
TLDR:
I want my images to size automatically in reference to the size of the window, but most of the time it just goes haywire.



1
u/Crafty_Magazine_4673 11h ago
while(true): rescale()