Python | Scrollview widget in kivy
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.
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:
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.
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:
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:
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