Why does tkinter frame expand along the bottom but creates blank space above in parent frame when parent frame is dragged larger?
12:39 06 Jun 2023

I have the following (Extracts) from my code:

# Class called by createWidgets

class dispRadio(Frame):
    def __init__(self, parent=None, **options):
        Frame.__init__(self, parent, **options)
        self.parent = parent
        self.pack(expand=NO, side=TOP)
        
        # other stuff dpne here
 
# Class called by main body

class NewMenu(Frame):                                   # an extended frame
    def __init__(self, parent=None):    # attach to top-level
        self.parent = parent
        Frame.__init__(self, parent)
        self.pack(side=TOP, expand=YES, fill=BOTH)
        self.main = self.master
        
        # other stuff done here, e.g. set variable for pandastable dataframe
        
        self.createWidgets()                       # attach frames/widgets
        
        self.PandasFrame = Frame(self.main, highlightbackground="green", highlightthickness=3) 
        self.PandasFrame.pack(side=TOP, fill=BOTH, expand=YES)
        
        self.pt = Table(self.PandasFrame, dataframe = category_receipts, width=1500, maxcellwidth=1500)
        self.pt.show()   
        
    def createWidgets(self):    
        self.mainWin = dispRadio(self, highlightbackground="blue", highlightthickness=1)
        self.smallWin = dispRadio2(self, highlightbackground="red", highlightthickness=1)

# Main Body

root = Tk()
nm = NewMenu(root)

root.mainloop()

This creates a button widget followed by the frame containing the pandastable, When I drag on the bottom of the main window, the pandastable window does increase the number of rows shown at the bottom of the frame; however, empty blank space is created between the buttons widget and the padnadstable frame. I would have expected the top of the pandastable frame to remain just below the buttons widgets and the growth only at the bottom of the frame. My question is why does the parent frame grow space (between the button widgets and the pandastable frame and not be filled by the pandastable frame?

I have tried various methods of packing and ordering of the frames, but I can't seem to find a way for the resizing of the main window to not grow empty space between the other frames instead of the frame filling the new space above it.

Example of frames before and after

Tried different methods of packing (fill, expand, sidew) or order of frame packing in parent. Also looked through pandastable documentation to see if it had anything to control it's parent frame but didn't find anything.

python pandas tkinter