Follow these steps to create Tab controls, which in tkinter are called Notebook:
- Create a new Python module and name it GUI_tabbed.py.
- At the top of the module, import tkinter:
import tkinter as tkfrom tkinter import ttk
- Create an instance of the Tk class:
win = tk.Tk()
- Add a title via the title attribute:
win.title ("Python GUI")
- Create tabControl using the ttk Notebook:
tabControl = ttk.Notebook(win)
- Add the tab to tabControl:
tabControl.add(tab1, text-'Tab 1')
- Use pack to make the control visible inside the GUI:
tabControl.pack(expand=1, fill="both")
The preceding instructions produce the following code, which can be found in the GUI_tabbed.py file:
- Run the preceding code. The following screenshot shows the ...