Tkinter - Bad resizing with "panedwindow" widgets:

Viewed 134

in my GUI I used two panedwindow widgets with two inside frames for each of them. All works as I axpected, except the resizing.. when I resize the frames, all widgets start to flick, and I really don't like to see it.

To understand better the issue, I took a piece of code from my real program and I simplified it as much as possible:

from tkinter import *
from tkinter import ttk

class MainWindow:
    def __init__(self):

        # main window:
        self.parent=Tk()
        self.parent.geometry("760x620+370+100")
        self.parent.title("Main Window")
        self.parent.configure(background="#f0f0f0")
        self.parent.minsize(760, 600)

        self.Frame1=PanedWindow(self.parent, orient=HORIZONTAL)
        self.Frame1.grid(row=0, column=0, padx=(5,4), pady=(6,0), sticky="nswe")
        self.parent.grid_columnconfigure(0, weight=1)
        self.parent.grid_rowconfigure(0, weight=1)

        self.Frame1_1=Frame(self.Frame1)
        self.Frame1_1.pack(side=LEFT)
        self.Frame1_2=Frame(self.Frame1)
        self.Frame1_2.pack(side=RIGHT)
        self.Frame1_1.grid_columnconfigure(0, weight=1)
        self.Frame1_1.grid_rowconfigure(0, weight=1)

        # Frame1_1:
        self.Frame1_1_1=PanedWindow(self.Frame1_1, orient=VERTICAL)
        self.Frame1_1_1.grid(row=0, column=0, sticky="nswe")
        
        self.MainNotebook=ttk.Notebook(self.Frame1_1_1)
        self.MainNotebook.pack(fill=BOTH, expand=True)
        self.MainNotebookFrame=Frame(self.MainNotebook, background="white")
        self.MainNotebookFrame.pack()
        self.MainNotebook.add(self.MainNotebookFrame, text="Tab1")

        self.Search1SV=StringVar()
        self.Search1Entry=ttk.Entry(self.MainNotebookFrame, textvariable=self.Search1SV)
        self.Search1Entry.pack(fill=BOTH, padx=5, pady=5)
        
        self.TVDFrame=Frame(self.MainNotebookFrame, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
        self.TVDFrame.pack(fill=BOTH, expand=True, padx=5, pady=(0,4))
        
        self.TVDFrame.grid_columnconfigure(1, weight=1)
        self.TVDFrame.grid_rowconfigure(1, weight=1)

        self.TreeView1=ttk.Treeview(self.TVDFrame, height=10, selectmode="browse")
        self.TreeView1.grid(row=0, column=0, columnspan=3, rowspan=3, sticky="nsew")

        self.HeaderFrame=Frame(self.TVDFrame, height=25, background="#d9ebf9")
        self.HeaderFrame.grid(row=0, column=0, columnspan=3, sticky="nsew")
        ttk.Label(self.HeaderFrame, text="Languages:", background="#d9ebf9").grid(row=0, column=0, pady=3)

        self.TreeView1SBY=ttk.Scrollbar(self.TVDFrame, orient="vertical", command=self.TreeView1.yview)
        self.TreeView1SBY.grid(row=0, column=2, rowspan=2, sticky="nse")
        self.TreeView1.configure(yscroll=self.TreeView1SBY.set)

        self.TreeView1.insert("", "end", text="Ciao")
        self.TreeView1.insert("", "end", text="Hola")
        self.TreeView1.insert("", "end", text="привет")

        Frame(self.TVDFrame, height=1, width=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=0, column=0, columnspan=3, sticky="new")
        Frame(self.TVDFrame, height=1, width=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=2, column=0, columnspan=3, sticky="ew")
        Frame(self.TVDFrame, width=1, height=4, background="white", highlightthickness=0, highlightbackground="white").grid(row=0, column=0, rowspan=3, sticky="ns")

        self.SecondNotebookFrame=Frame(self.Frame1_1_1)
        self.SecondNotebookFrame.pack(fill=BOTH)
        self.SecondNotebook=ttk.Notebook(self.SecondNotebookFrame)
        self.SecondNotebook.pack(fill=BOTH, expand=True, pady=(2,1))

        self.OptionalFrame1=Frame(self.SecondNotebook, background="white")
        self.OptionalFrame1.pack()
        self.SecondNotebook.add(self.OptionalFrame1, text="Tab1")
        self.OptionalFrame2=Frame(self.OptionalFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
        self.OptionalFrame2.pack(fill=BOTH, expand=True, padx=5, pady=(5,4))

        self.PBFrame1=Frame(self.Frame1_1, background="white", highlightbackground="#d9d9d9", highlightthickness=1)
        self.PBFrame1.grid(row=1, column=0, padx=(1,3), pady=(3,1), sticky="nswe")
        self.PBFrame2=Frame(self.PBFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
        self.PBFrame2.pack(fill=BOTH, padx=5, pady=5)
        self.Progressbar=ttk.Progressbar(self.PBFrame2, mode="determinate", maximum=100, value=0)
        self.Progressbar.pack(fill=BOTH, padx=10, pady=10)

        # frame Frame1_2:
        self.WorkNotebook=ttk.Notebook(self.Frame1_2)
        self.WorkNotebook.pack(fill=BOTH, expand=True, pady=(1,0))
        self.WorkNotebookFrame=Frame(self.WorkNotebook, background="white")
        self.WorkNotebookFrame.pack()    
        self.WorkNotebook.add(self.WorkNotebookFrame, text="Tab1")
        self.WorkNotebookFrame=Frame(self.WorkNotebookFrame, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
        self.WorkNotebookFrame.pack(fill=BOTH, expand=True, padx=5, pady=(5,4))

        self.PBFrame1=Frame(self.Frame1_1, background="white", highlightbackground="#d9d9d9", highlightthickness=1)
        self.PBFrame1.grid(row=1, column=0, padx=(1,3), pady=(3,1), sticky="nswe")
        self.PBFrame2=Frame(self.PBFrame1, background="white", highlightbackground="#7a7a7a", highlightthickness=1)
        self.PBFrame2.pack(fill=BOTH, padx=5, pady=5)
        self.Progressbar=ttk.Progressbar(self.PBFrame2, mode="determinate", maximum=100, value=0)
        self.Progressbar.pack(fill=BOTH, padx=10, pady=10)

        self.Frame1.add(self.Frame1_1, minsize=230)
        self.Frame1.add(self.Frame1_2, minsize=250)
        self.Frame1_1_1.add(self.MainNotebook, minsize=56)
        self.Frame1_1_1.add(self.SecondNotebookFrame, minsize=104)

        # end:
        self.parent.mainloop()

if __name__=="__main__":
    app=MainWindow()

in addition I attached also a GIF and this image shows exactly when the issue happen:

enter image description here

how can I solve the resizing issue?

0 Answers
Related