Open In App
Related Articles

Python | File chooser 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.


The FileChooser module provides various classes for describing, displaying, and browsing file systems. It is Simple like the My computer from where we can choose any file in the system.  

  • The FileChooserListView displays file entries as text items in a vertical list, where folders can be collapsed and expanded.
  • The FileChooserIconView presents icons and text from left to right, wrapping them as required.

Note: The both above points provide for scrolling, selection and basic user interaction. 

Basic Approach 
1) import kivy
2) import kivyApp
3) import Boxlayout
4) Set minimum version(optional)
5) create layout class
6) create App class
7) create .kv file
8) return Layout/widget/Class(according to requirement)
9) Run an instance of the class or App

Implementation of the Approach:
.py file 


# Program to explain how to use File chooser 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  
# BoxLayout arranges widgets in either in
# a vertical fashion that is one on top of
# another or in a horizontal fashion
# that is one after another.
from kivy.uix.boxlayout import BoxLayout
# create the layout class
class Filechooser(BoxLayout):
    def select(self, *args):
        try: self.label.text = args[1][0]
        except: pass
# Create the App class
class FileApp(App):
    def build(self):
        return Filechooser()
# run the App
if __name__ == '__main__':

.kv file 


#, kv file implementation
    label: label
    # Providing the orientation
    orientation: 'vertical'
    # Creating the File list / icon view
        # Creating list view one side
                    rgb: .4, .5, .5
                    pos: self.pos
                    size: self.size
        # Creating Icon view other side
                    rgb: .5, .4, .5
                    pos: self.pos
                    size: self.size
    # Adding label
        id: label
        size_hint_y: .1
                rgb: .5, .5, .4
                pos: self.pos
                size: self.size




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 : 29 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials