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 Desktop applications.
Kivy Tutorial – Learn Kivy with Examples.
Scroll view:
The ScrollView widget provides a scrollable/pannable viewport that is clipped at the scrollview’s bounding box. Scroll view accepts only one child and applies a window to it according to 2 properties:
- scroll_x
- scroll_y
To determine if the interaction is a scrolling gesture, these properties are used:
- scroll_distance: the minimum distance to travel, defaults to 20 pixels.
- scroll_timeout: the maximum time period, defaults to 55 milliseconds.
Note:
To use the scrollview you must have to import it:
from kivy.uix.scrollview import ScrollView
Basic Approach:
1) import kivy
2) import kivyApp
3) import scroll view
4) import string property
5) Set minimum version(optional)
6) create the scroll view class
7) Build the .kv file within the .py file
8) Run an app
Implementation of the code:
Python3
import kivy
from kivy.app import App
kivy.require( '1.9.0' )
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView
from kivy.properties import StringProperty
from kivy.base import runTouchApp
from kivy.lang import Builder
Builder.load_string(
)
class ScrollableLabel(ScrollView):
text = StringProperty('')
runTouchApp(ScrollableLabel())
|
Output:

You can also change color of ScrollBar and its width as shown below code but for that, you have to use properties of ScrollView like
- bar_color: It requires a list in RGB format for specifying bar color
- bar_width: It requires a number for specifying the bar size
Code For Changing Bar Color and Bar width:
Python3
from kivy.app import App
from kivy.lang import Builder
class uiApp(App):
def build( self ):
return Builder.load_string(
BoxLayout:
size_hint: ( 1 , 1 )
ScrollView:
bar_color: [ 0 , 0 , 255 , 1 ]
bar_width: 12
BoxLayout:
size: ( self .parent.width, self .parent.height - 1 )
id : container
orientation: "vertical"
size_hint_y: None
height: self .minimum_height
canvas.before:
Color:
rgba: rgba( "#50C878" )
Rectangle:
pos: self .pos
size: self .size
Label:
size_hint: ( 1 , None )
height: 300
markup: True
text: "[size=78]GeeksForGeeks[/size]"
Label:
size_hint: ( 1 , None )
height: 300
markup: True
text: "[size=78]GeeksForGeeks[/size]"
Label:
size_hint: ( 1 , None )
height: 300
markup: True
text: "[size=78]GeeksForGeeks[/size]"
Label:
size_hint: ( 1 , None )
height: 300
markup: True
text: "[size=78]GeeksForGeeks[/size]"
)
uiApp().run()
|
Output:
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!