2025, Oct 21 15:00

CTkTabview not filling vertical space in CustomTkinter: why it happens and how to fix it with anchor='s'

CustomTkinter CTkTabview not filling vertical space? Learn the actual bug, how to verify it, and the simple fix: set anchor='s' - no changes to grid or sticky.

CTkTabview not filling vertical space in customtkinter: what’s going on and how to fix it

Sometimes a CTkTabview looks like it takes only about two-thirds of the window height, leaving a large empty area below. The grid is configured to stretch, sticky is set to nsew, yet the content refuses to occupy the full vertical space. Let’s walk through a minimal example, the root cause, and the fix.

Reproducible snippet

import customtkinter

class MainWindow(customtkinter.CTk):
    def __init__(self):
        super().__init__()

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.tabs = TabBook(self)
        self.tabs.grid(column=0, row=0, sticky="nsew")

class TabBook(customtkinter.CTkTabview):
    def __init__(self, master):
        super().__init__(master)
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.add("Tab")

        self.tab("Tab").grid_columnconfigure(0, weight=1)
        self.tab("Tab").grid_rowconfigure(0, weight=1)
        self.tab("Tab").grid(column=0, row=0, sticky="nsew")

What actually happens

This appears to be a bug in customtkinter. The CTkTabview instance itself stretches to fill the window as expected, but the internal content area of the CTkTabview only occupies the top portion of the widget. The remainder of the space is left unused. You can confirm this by placing a visible widget inside the tab; it will stay pinned to the top while the bottom space remains empty.

The fix

Initialize CTkTabview with anchor set to "s". With anchor="s", the widget behaves properly and the tab content uses the available vertical space as intended.

import customtkinter

class MainWindow(customtkinter.CTk):
    def __init__(self):
        super().__init__()

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.tabs = TabBook(self)
        self.tabs.grid(column=0, row=0, sticky="nsew")

class TabBook(customtkinter.CTkTabview):
    def __init__(self, master):
        super().__init__(master, anchor='s')
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.add("Tab")

        self.tab("Tab").grid_columnconfigure(0, weight=1)
        self.tab("Tab").grid_rowconfigure(0, weight=1)
        self.tab("Tab").grid(column=0, row=0, sticky="nsew")

Why this matters

When layouts look wrong, it’s easy to suspect grid weights, sticky flags, or container sizing. In this case, those pieces are already correct; the issue lives inside CTkTabview. Knowing that the widget fills the parent while its content area does not helps you avoid chasing phantom grid bugs in your own code.

There is an open issue tracking this behavior in the CustomTkinter repository: github.com/TomSchimansky/CustomTkinter/issues/2739

Conclusion

If your CTkTabview appears to cap out at the top portion of the window, leave your grid and sticky configuration as is and set anchor="s" when creating CTkTabview. Until the upstream bug is resolved, this adjustment keeps tab content aligned with the available space and restores the expected full-height layout.

The article is based on a question from StackOverflow by frenzy and an answer by J Earls.