If I'm using grid(), why the widgets don't scale when I resize the window? If I'm using grid(), why the widgets don't scale when I resize the window? tkinter tkinter

If I'm using grid(), why the widgets don't scale when I resize the window?


You have several problems in your code that are working together to prevent the widgets from scaling (and by "widgets", I assume you mean the text widget).

First, you use grid to put the instance of App in the root window. However, you haven't set the sticky attribute, so the app won't grow and shrink. If it doesn't grow and shrink, neither will its contents.

Also, because you're using grid, you need to give row zero and column zero a positive weight so that tkinter will allocate extra space to it. However, since this is the only widget in the root window, you can use pack and solve the problem by replacing the call to grid with a call to pack:

self.pack(fill="both", expand=True)

Next, you use grid to add the text widget to the canvas. You haven't used the sticky option, so even if the space allocated to it grows, the widget will stay centered in the space. You need to use the sticky attribute to tell it to "stick" to all sides of the area it is given:

self.content_area.grid(row=1, column=0, sticky="nsew")

Finally, you haven't given any columns any "weight", which tells tkinter how to allocate extra space. When a window managed by grid resizes, any extra space is given to the rows and columns according to their weight. By default a row and column has zero weight, so it does not get any extra space.

To get the text area to grow as the window grows, you need to give column zero and row one a positive weight:

self.grid_rowconfigure(1, weight=1)self.grid_columnconfigure(0, weight=1)