Akascape / CTkMenuBar

Modern menu/tool bar widget library for customtkinter. (extension/add-on)
Creative Commons Zero v1.0 Universal
111 stars 9 forks source link

Menu Bar returns error and disappear #9

Closed RightBrainStudio closed 7 months ago

RightBrainStudio commented 10 months ago

I'm using Ctkmenubar and Ctktabview in my program, I tried to delete a tab in the Ctktabview, the menu bar disappeared and returns some error. Example:

import customtkinter
from CTkMenuBar import *

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

        self.tabview = customtkinter.CTkTabview(self)
        self.tabview.grid()

        self.tabview.add("Add Tab")

        self.add_button = customtkinter.CTkButton(self.tabview.tab("Add Tab"), text="Add", width=100, command= self.add_tab)
        self.add_button.grid()

        menu = CTkTitleMenu(master=self)

        file_button = menu.add_cascade("File")
        file_dropdown = CustomDropdownMenu(widget=file_button)
        file_dropdown.add_option(option="Open")
        save_as = file_dropdown.add_submenu("Save as")

        edit_button = menu.add_cascade("Edit")
        edit_dropdown = CustomDropdownMenu(widget=edit_button)
        edit_dropdown.add_option(option="Undo")
        edit_dropdown.add_option(option="Redo")

    def add_tab(self):
        self.tabview.add(self.tab_name)

        self.del_button = customtkinter.CTkButton(self.tabview.tab(self.tab_name), text="Del", width=100, command= self.del_tab)
        self.del_button.grid(row=1)

        self.tabview.set(self.tab_name)
        self.tab_name += 1

    def del_tab(self):
        self.current_tab = self.tabview.get()
        self.tabview.delete(self.current_tab)

if __name__ == "__main__":
    app = App()
    app.mainloop()
zlElo commented 10 months ago

I think the problem is that you use grid. The source code of this project uses pack instead of grid.

P.S.: Next time pls post your error too, only you code doesn't help much ;)

Greets @zlElo

Akascape commented 7 months ago

@RightBrainStudio Ok it's fixed now, was a small issue.