CTkMenuBar icon indicating copy to clipboard operation
CTkMenuBar copied to clipboard

TypeError: super(type, obj): obj must be an instance or subtype of type

Open Dumbliidore opened this issue 1 year ago • 0 comments

This is my code:

import customtkinter
from CTkMenuBar import CTkTitleMenu, CustomDropdownMenu
from CTkTable import CTkTable


class ImageDownloader(customtkinter.CTk):
    def __init__(self) -> None:
        super().__init__()

        # self.title("DownloadImgTool")
        self.title("")
        self.width = 900
        self.height = 600
        self.grid_rowconfigure(0, weight=1)  # configure grid system
        self.grid_columnconfigure(0, weight=1)  # configure grid system

        x, y = (
            (self.winfo_screenwidth() - self.width) // 2,
            (self.winfo_screenheight() - self.height) // 2 - 30,
        )

        self.geometry(f"{self.width}x{self.height}+{x}+{y}")
        self.resizable(False, False)

        self.create_menu()
        self.set_table_component()

    # 创建 menu
    def create_menu(self) -> None:
        menu = CTkTitleMenu(
            master=self, title_bar_color="transparent", padx=0, x_offset=60
        )
        help_menu = menu.add_cascade("帮助", fg_color="transparent", hover_color="gray")

        help_dropdown = CustomDropdownMenu(help_menu)
        help_dropdown.add_option("文档")

    def set_table_component(self) -> None:
        value = [
            ["ID", "ImgID", "Suffix", "", ""],
        ]

        table_label = customtkinter.CTkLabel(self, text="Table")
        table_label.pack(pady=(10, 2), anchor="center")
        scroll_label_frame = customtkinter.CTkScrollableFrame(self, height=20)

        scroll_label_frame.pack(fill="both", expand=True, padx=(15, 15), pady=(0, 10))
        self.table = CTkTable(
            master=scroll_label_frame,
            row=1,
            column=5,
            values=value,
            corner_radius=0,
        )
        # TODO: This is a bug, the font of the first row will be invalid when the table was changed.
        # self.table.edit_row(0, font=self.header_font)
        self.table.add_row([1, 1, "xxz", None, None])
        self.table.edit_column(0, width=1)
        self.table.edit_column(1, width=1)
        self.table.pack(fill="both", expand=True)


if __name__ == "__main__":
    app = ImageDownloader()
    app.mainloop()

image

Seems to have been influenced by CTkTable. Because if I comment out self.set_table_component(), it will work.

Dumbliidore avatar Jan 13 '25 09:01 Dumbliidore