Skip to content
Related Articles

Related Articles

Improve Article

Python | Tabbed panel in kivy

  • Last Updated : 06 Feb, 2020

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 functioninging 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:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :