I have notebook widget of class ttk.Notebook. In this notebook I'm adding many tabs:
notebook.add(child=my_object, text='my tab')
How can I get tab object and not tab name?
UPDATE 1
So, there is children dictionary. OK that brings next problem.
What I really want to do is to take my hands on object of active tab in Notebook. So I have this:
notebook.children[notebook.select().split('.')[2]])
but it looks ugly. Unfortunately widget name returned by select() has not exactly same format as widget names in children[]. Is there any method of reliable translation of one format to another or split() will never fail in this situation?
This is demo of problem:
#!/usr/bin/env python3
from tkinter import *
from tkinter.ttk import *
class App(Tk):
def __init__(self):
super().__init__()
notebook = Notebook(self)
notebook.add(child=Frame(notebook), text='tab1')
notebook.add(child=Frame(notebook), text='tab2')
notebook.add(child=Frame(notebook), text='tab3')
notebook.pack()
print('Tabs are: ', notebook.children.keys())
print('Active tab: ', notebook.select())
print(type(notebook.children[notebook.select().split('.')[2]]))
App().mainloop()
my_objectto variable and use this variable.