0

I have a Tkinter app, where the left side of a PanedWindow uses a frames container as described here, and the right side has a ScrolledText used for logging as described here. I'm also using this to resize the frames in the frames container, as they have different sizes.

My problem is that whenever a different frame is showed using the show_frame(..) method from here, the right side (the ScrolledText) doesn't resize to match the new frame size and overrides the left frame content.

This is the code part that constructs the PanedWindow and frames container.

class Main(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        self.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.geometry('1366x768')
        self.resizable(True, True)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        # Horizontal pane
        self.horizontal_pane = tk.PanedWindow(self, orient=HORIZONTAL)
        self.horizontal_pane.grid(row=0, column=0, sticky="nsew")
        # Frames container
        self.container = tk.Frame(self.horizontal_pane)
        self.horizontal_pane.add(self.container)
        # Log frame
        self.console_frame = tk.Frame(self.horizontal_pane)
        self.console_frame.columnconfigure(0, weight=1)
        self.console_frame.rowconfigure(0, weight=1)
        self.horizontal_pane.add(self.console_frame, stretch='always')

How can I fix that?

1 Answers1

0

I managed to solve it by editing the show_frame() method:

def show_frame(self, page_name):
    for frame in self.frames.values():
        frame.grid_remove()
    self.horizontal_pane.grid_remove() # Add this
    frame = self.frames[page_name]
    frame.grid()
    self.horizontal_pane.grid() # And that

Not sure if that's the right way though, but now whenever a new frame is shown, the ScrolledText on the right side is resized to match the left frame size.