In this Python TKinter article i want to show you How To Create TabWidgets In Python
TKinter, so you can watch my previous articles on Python TKinter GUI Development.
Also you can read more articles on Python GUI Development
1: PyQt5 GUI Development Tutorials
2: Pyside2 GUI Development Tutorials
3: wxPython GUI Development Tutorials
4: Kivy GUI Development Tutorials
This is the complete code for Creating TabWidgets In Python TKinter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import tkinter as tk from tkinter import ttk class App(tk.Tk): def __init__(self): super(App, self).__init__() self.title("Tkinter Tab Widgets") self.minsize(600,400) self.wm_iconbitmap("icon.ico") tabControl = ttk.Notebook(self) tab1 = ttk.Frame(tabControl) tabControl.add(tab1, text = "Tab 1") tab2 = ttk.Frame(tabControl) tabControl.add(tab2, text = "Tab 2") tabControl.pack(expan = 1, fill = "both") app = App() app.mainloop() |
These are the imports that we need for this article, basically it is tkinter library, also we are going
to import ttk from tkinter .
1 2 |
import tkinter as tk from tkinter import ttk |
In here basically we have set the window title, window icon and window size. make sure that
you have added an icon to your working directory.
1 2 3 |
self.title("Tkinter Tab Widgets") self.minsize(600,400) self.wm_iconbitmap("icon.ico") |
So creating of TabWidgets in TKinter are so easy, i dont want to add widgets in this article, iam going to just create TabWidgets. and i want to create my TabWidgets in my main App class that extends from tk.TK. so by using this line of code you can create your TabWidget.
1 |
tabControl = ttk.Notebook(self) |
Run the code and this will be the result
Also you can watch the complete video tutorial for this article
Subscribe and Get Free Video Courses & Articles in your Email