Search code examples
pythontkinterresizewindow

Change window size each tab tkinter notebook


I am a new tkinter user, and I was starting to make a notebook of some math programs. I wanted to make it so that the size of the notebook window changes based on the tab. So in tab1, there are more widgets, so that when packed together they take up less space than tab2. But when I go to tab2 the window is the same size, leaving a lot of black space. How can I get rid of that?

Thank you


Solution

  • I'm not sure if the notebook widget would normally allow that, but you could try making sure that your window/frames are set to allow propagation/expansion depending on what geometry manager you are using.

    see the following:

    pack geometry manager

    grid geometry manager

    the other way of course would be to bind your own resizing methods to the tab change:

    notebook.bind("<<NotebookTabChanged>>", resizingfunction)
    

    and then you could either call the geometry function on the parent window (assuming its the direct parent) or the height and width of the parent frame

    James