Skip to content

CTkTabview does not properly pack tabs unless anchor is in the "s" row #2739

@johnson-earls

Description

@johnson-earls

When CTkTabview is created with an anchor that is not sw, s, or se, it creates child frames that do not expand to fill the tab area.
This can be seen with the following simple app:

import customtkinter
import pprint

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

        anchors = {
            'nw': (0,0),
            'n': (1,0),
            'ne': (2,0),
            'w': (0,1),
            'center': (1,1),
            'e': (2,1),
            'sw': (0,2),
            's': (1,2),
            'se': (2,2),
        }
        self.tabs = {}
        for (anchor,(gcol,grow)) in anchors.items():
            tabview = customtkinter.CTkTabview(self, anchor=anchor)
            self.tabs[anchor] = tabview
            tabview.grid(column=gcol, row=grow, sticky="nsew")
            tab = tabview.add(anchor)
            tab.grid_columnconfigure(0, weight=1)
            tab.grid_rowconfigure(0, weight=1)
            tab.grid(column=0, row=0, sticky="nsew")
            tab.tabInfo = TabInfo(tab)
            tab.tabInfo.grid(column=0, row=0, sticky="nsew")

class TabInfo(customtkinter.CTkLabel):
    def __init__(self, master):
        super().__init__(master)
        self.setup_text()
        self.bind("<Configure>", self.reconfigure)

    def reconfigure(self, event):
        self.setup_text()

    def setup_text(self):
        self.configure(text=self.winfo_geometry())

if __name__ == '__main__':
    app = App()
    app.mainloop()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions