How to Use Multiple Tabs in Tkinter – Python GUI Tutorial

Posted by

Multiple Tabs in Tkinter – Python GUI Tutorial

Multiple Tabs in Tkinter – Python GUI Tutorial

In this tutorial, we will learn how to create multiple tabs in a Tkinter GUI application using Python.

Step 1: Import the necessary libraries

    import tkinter as tk
    from tkinter import ttk
  

Step 2: Create the main Tkinter window

    root = tk.Tk()
    root.title("Multiple Tabs Tutorial")
  

Step 3: Create the Tab Control

    tab_control = ttk.Notebook(root)
    
    tab1 = ttk.Frame(tab_control)
    tab2 = ttk.Frame(tab_control)
    
    tab_control.add(tab1, text='Tab 1')
    tab_control.add(tab2, text='Tab 2')
  

Step 4: Add widgets to each tab

    label1 = tk.Label(tab1, text="This is Tab 1")
    label1.pack(padx=20, pady=20)
    
    label2 = tk.Label(tab2, text="This is Tab 2")
    label2.pack(padx=20, pady=20)
  

Step 5: Display the Tabs

    tab_control.pack(expand=1, fill="both")
    
    root.mainloop()
  

By following these steps, you can create a simple GUI application with multiple tabs using Tkinter in Python.

0 0 votes
Article Rating
11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@deagin3830
1 month ago

Do you have any experience with GIS work? I'd love a video on rotating raster layers in mapbox. It's proving difficult because the distance in feet per degrees of longitude changes as you move across longitude. So, rotating a 4 sided object with each point being coordinates has been an interesting problem to solve.

Ps been watching ypur videos on genetic algorithm lately, went to the latest and saw this tutorial for Tkinter which I am also using. Your content is relevant and helpful, I may be become a regular

@nihilspace
1 month ago

Super useful, thanks! Still keeping my fingers crossed for a Protocol Buffer tut 🤞

@MennChanrattanak
1 month ago

❤Please design a nice modern Treeview with CustomTkinter and do fully complete functions or methods class with json file such as
✅ Display data into Treeview,
✅ Insert,
✅ Delete,
✅ Update,
✅ Filter,
✅ Auto complete search,
✅ Selected and multiple Selected (getting data from Treeview to EntryBox, CheckBox,…)

and so on …

Thank you very much before Done this! 🙏comment image

@Oodle-ox2vf
1 month ago

Excellent content as usual. 🙂 Just the right speed, most tutorials are too slow, and get off topic.

@atheralisyed9846
1 month ago

Nice 🙂

@philtoa334
1 month ago

Thx_.

@fallenstar2297
1 month ago

Can you do a tutorial in BACnet device in python to send valu on the BACnet ethernet ?

@mortezanaghavimoghadam8258
1 month ago

I think we have to install tkinter in Linux using pip

@StyleOFBeyond
1 month ago

what i need just in time 👹

@dipeshsamrawat7957
1 month ago

Nice. Keep it up 💯

@Motivation7x
1 month ago

The first comment wow 🎉