Adding tkinter modules to notebook tabs

Rich Shepard rshepard at appl-ecosys.com
Sat Apr 4 16:31:30 EDT 2020


On Sat, 4 Apr 2020, Christian Gollwitzer wrote:

> I'm not sure I fully understand it, because a "module" is not defined in the 
> language of tkinter.

Christian,

True, but it is in Python: a file ending in .py which, in this case,
contains a class of tkinter widgets.

> Is it correct, you want to know how to place more than one widget - a
> arrangement of widgets - onto a notebook tab?

Yes, as they are defined and laid out in separate files/modules.

> This is achieved by a ttk.Frame() widget, which holds all the other stuff, 
> and then you place the frame onto the notebook:
>
> n=ttk.Notebook()
> f1=ttk.Frame()
> # put all your stuff into f1
> n.add(f1, text="Module1")
> # repeat for your other "modules"

This looks to me like it's adding the text, "Module1" to the tab.

Here:

nb = ttk.Notebook(Main)
     ...
     page3 = ttk.Frame(nb)
     ...
     # add titles to tabs
     nb.add(page3, text='Biota')
     ...

This puts the text on each notebook tab, correct?

If so, how do I add

class BiotaDataForm(Tk.Frame):

which defines all the widgets in the module in views/biota.py into the body
of the notebook's page3?

Thanks,

Rich




More information about the Python-list mailing list