Replies: 5 comments 5 replies
-
Hi, it's possible if you use the grid geometry manager instead of place or pack. I don't know if you use grid already, but when you set the weights of the cells and the sticky options of the widgets properly, the widgets adapt to the window size automatically. I created a small example with the grid manager in the wiki here: https://github.com/TomSchimansky/CustomTkinter/wiki/App-structure-and-layout#small-onefile-example-app-with-grid (I would recommend to always use the grid geometry manager) |
Beta Was this translation helpful? Give feedback.
-
Thanks for the fast reply. Here is the code of the example from above: How would I need to adjust it so that all widgets are shown and not truncated resp hidden.
|
Beta Was this translation helpful? Give feedback.
-
You need to set the weight of the grid cells. By default all the cells have a weight of 0 so they will not expand or shrink together, they will be fixed size: self.grid_rowconfigure((1, 2), weight=1)
self.grid_columnconfigure((1, 2, 3, 4, 5, 6), weight=1) Also not that the grid indexing begins at 0 and not at 1, but here it doesn't matter. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
The CTkLabels are resizing automatically, you can see it if you define a |
Beta Was this translation helpful? Give feedback.
-
First of all, I absolutely love it! Kudos!
About my question:
I want to avoid defining a fixed geometry but rather let the app auto-size to fit all widgets.
Background is that defining fixed width&height may look good when testing on screen A with resolution 3840x2160 with scale 200% but when opening on screen B with different resolution and scale leads to certain widgets pushed together or not shown at all.
This happens when not defining the geometry. Certain widgets are not shown. The default geometry seems to be a square, not adapting its size based on its widgets.
What I imagine is something like that - basically auto-size the window to fit all widgets:
Thanks in advance!
Tim
Beta Was this translation helpful? Give feedback.
All reactions