Виджет выходит за границы окна

На stackoverflow нашел класс, позволяющий создавать frame со scrollbar:

class VerticalScrolledFrame(tk.LabelFrame):
"""A pure Tkinter scrollable frame that actually works!
* Use the 'interior' attribute to place widgets inside the scrollable frame.
* Construct and pack/place/grid normally.
* This frame only allows vertical scrolling.
"""

def __init__(self, parent, *args, **kw):
    tk.LabelFrame.__init__(self, parent, *args, **kw)

    # Create a canvas object and a vertical scrollbar for scrolling it.
    vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
    vscrollbar.pack(fill=tk.Y, side=tk.RIGHT, expand=tk.FALSE)
    canvas = tk.Canvas(self, bd=0, highlightthickness=0,
                       yscrollcommand=vscrollbar.set)
    canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.TRUE)
    vscrollbar.config(command=canvas.yview)

    # Reset the view
    canvas.xview_moveto(0)
    canvas.yview_moveto(0)

    # Create a frame inside the canvas which will be scrolled with it.
    self.interior = interior = tk.Frame(canvas)
    interior_id = canvas.create_window(0, 0, window=interior,
                                       anchor=tk.NW)

    # Track changes to the canvas and frame width and sync them,
    # also updating the scrollbar.
    def _configure_interior(event):
        # Update the scrollbars to match the size of the inner frame.
        size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
        canvas.config(scrollregion="0 0 %s %s" % size)
        if interior.winfo_reqwidth() != canvas.winfo_width():
            # Update the canvas's width to fit the inner frame.
            canvas.config(width=interior.winfo_reqwidth())

    interior.bind('<Configure>', _configure_interior)

В моем окне идут три рамки подряд, последняя рамка содержит вот такую рамку с прокруткой и кнопку, но последняя рамка вылезает за пределы окна, если развернуть его на весь экран. Не удалось нагуглить, как решить эту проблему.

Упаковывается все вот так:

frm_params_base = tk.LabelFrame(frm_main, text='Параметры системы', pady=0)
frm_params_base.grid(row=2, column=0, sticky=tk.NSEW)

frm_params = VerticalScrolledFrame(frm_params_base)
frm_params.pack(side=tk.TOP, expand=True, pady=1)
tk.Button(frm_params_base, text='Рассчитать', command=init_params).pack(side=tk.TOP, pady=1)

А выглядит в результате вот так:введите сюда описание изображения

Как можно увидеть, нижняя рамка вылезла за экран и кнопка вообще не видна. Подскажите, пожалуйста, как это можно исправить. Спасибо!


Ответы (0 шт):