Repeated replacement of a widget with a widget of equal size - how its done? Repeated replacement of a widget with a widget of equal size - how its done? tkinter tkinter

Repeated replacement of a widget with a widget of equal size - how its done?


What I would do is use an intermediate frame which controls the size. Then, you can pack either the red or blue frame inside this frame.

Start by creating a subframe with the size you want. Lets say you want the area to be 500x500:

subframe = tk.Frame(contentFrame, width=500, height=500)subframe.pack(fill="both", expand=True)

Next, turn geometry propagation off so that the frame won't grow or shrink to fit its children:

subframe.pack_propagate(False)

Finally, put your red and blue frames inside this subframe:

canvas = tkinter.Canvas(master=subframe, bg="#F00", highlightthickness=0, borderwidth=0)xmlEditor = tkinter.Text(master=subframe, bg="#00F", highlightthickness=0, borderwidth=0)