0

I have frame and inside i have Notebook (Tabs). Each tab represent diffrent frame. Besides the Notebook, i also have Menu. What i'm trying to do is when i click on the menu, for example 'file' , I want to change the current Frame with a new Frame.

I'm having problem with the logic, because i used OOP to build the Notebook.

Code

class Layout:
def __init__(self, window):
    self.window = window
    window.title('Insta Bot')
    window.geometry('800x600')

    # menu config
    menu = Menu(window)
    sub_menu = Menu(menu, tearoff=0)
    menu.add_cascade(label='Main', menu=sub_menu)
    sub_menu.add_command(label='Accounts')
    sub_menu.add_command(label='Exit')
    window.config(menu=menu)

    # tab config
    tab_control = ttk.Notebook(window)

    hash_tag_tab = TabHashTag(tab_control)
    followers_tab = TabFollowers(tab_control)
    location_tab = TabLocation(tab_control)

    tab_control.add(hash_tag_tab, text='Hash Tag')
    tab_control.pack(expand=1, fill="both")
    tab_control.add(followers_tab, text='Followers')
    tab_control.pack(expand=1, fill="both")
    tab_control.add(location_tab, text='Location')
    tab_control.pack(expand=1, fill="both")

    # status bar config
    status_bar = Label(window, text="status bar", bd=1, relief=SUNKEN, anchor=W)
    status_bar.pack(side=BOTTOM, fill=X)

Here I'm creating the Menu,Notebook and also the status bar. Also i push to the Tab control 3 Frame classes (hash_tag_tab,followers_tab ...). What i want to do is when the user click on the menu, to change the frames between Notebook to other frame.

I understand that i need to use a method called tkraise(), but i cant figure the logic,how to do that. Any idea how can i use it in this code? I hope the question is clear, if not please hit me up.

E.Bolandian
  • 553
  • 10
  • 35

0 Answers0