Open In App
Related Articles

Python | Tabbed panel in kivy

Improve Article
Save Article
Like Article

Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications

👉🏽 Kivy Tutorial – Learn Kivy with Examples.

Tabbed panel

The TabbedPanel widget manages different widgets in tabs, with a header area for the actual tab buttons and a content area for showing the current tab content.

The TabbedPanel provides one default tab.

To use it must import :
from kivy.uix.tabbedpanel import TabbedPanel

Basic Approach:
1) import kivy
2) import kivy App
3) import floatlayout
4) import tabbedpanel
5) set minimum version(optional)
6) Create Tabbed panel class
7) create the App class
8) create .kv file:
       # create multiple tabs in it.
       # Do there functioning also.
9) return the widget/layout etc class
10) Run an instance of the class

Implementation Of Approach:

.py file

# Program to explain how to create tabbed panel App in kivy  
# import kivy module     
import kivy   
# base Class of your App inherits from the App class.     
# app:always refers to the instance of your application    
from import App  
# this restrict the kivy version i.e   
# below this kivy version you cannot   
# use the app or software   
# to  use this must have to import it
from kivy.uix.tabbedpanel import TabbedPanel
# Floatlayout allows us to place the elements
# relatively based on the current window
# size and height especially in mobiles
from kivy.uix.floatlayout import FloatLayout
# Create Tabbed class 
class Tab(TabbedPanel):
# create App class
class TabbedPanelApp(App):
    def build(self):
        return Tab()
# run the App
if __name__ == '__main__':

.kv file

# .kv file of tabbed panel
    # creating the size
    # and the alignment of the tab 
    size_hint: .5, .5
    pos_hint: {'center_x': .5, 'center_y': .5}
    do_default_tab: False
    # Create tab 1
        text: 'Tab 1'
            text: "First tab"
    # Create 2nd tab
        text: 'Tab 2'
                text: 'Press button'
                text: 'Click it'
    # Create 3rd tab
        text: 'Tab 3'
            text: '\n'.join(("How are you GFG's???"))


Tab 1:

Tab 2:

Tab 3:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 18 Oct, 2021
Like Article
Save Article
Similar Reads
Complete Tutorials