Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- main = Tk()
- def printframe(event):
- frame_name = book.tabs()[event.widget.index("current")] #todo: identify the name of the frame in a way that works even with the custom Notebook that has X buttons.
- frame = book.nametowidget(frame_name)
- print(frame, type(frame))
- book = ttk.Notebook(main)
- book.bind("<<NotebookTabChanged>>", printframe)
- book.grid()
- for x in range(5):
- tabname = 'Book tab that has been cut short'
- if len(tabname) > 10:
- tabname = ''.join(tabname[:10])
- frame = Frame(book, width=200, height=200)
- Label(frame, text=f'This is tab {x}').grid(padx=50, pady=50, sticky=NSEW)
- book.add(frame, text=f'{tabname}')
- main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement