Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter import ttk
  3.  
  4. main = Tk()
  5.  
  6. def printframe(event):
  7. 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.
  8. frame = book.nametowidget(frame_name)
  9. print(frame, type(frame))
  10.  
  11. book = ttk.Notebook(main)
  12. book.bind("<<NotebookTabChanged>>", printframe)
  13. book.grid()
  14.  
  15. for x in range(5):
  16. tabname = 'Book tab that has been cut short'
  17. if len(tabname) > 10:
  18. tabname = ''.join(tabname[:10])
  19. frame = Frame(book, width=200, height=200)
  20. Label(frame, text=f'This is tab {x}').grid(padx=50, pady=50, sticky=NSEW)
  21. book.add(frame, text=f'{tabname}')
  22.  
  23. main.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement