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 Desktops applications.
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:
1) scroll_x
2) scrool_y
To determine if 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:
# Program to explain how to use scroll view 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 kivy.app import App # this restrict the kivy version i.e # below this kivy version you cannot # use the app or software kivy.require('1.9.0') # The Label widget is for rendering text from kivy.uix.label import Label # The ScrollView widget provides a scrollable view from kivy.uix.scrollview import ScrollView # Property that represents a string value from kivy.properties import StringProperty # Static main function that starts the application loop. from kivy.base import runTouchApp # Builder is a global Kivy instance used in # widgets that you can use to load other # kv files in addition to the default ones. from kivy.lang import Builder # Build the .kv file Builder.load_string(''' # Define the scroll view <ScrollableLabel>: text: 'You are learning Kivy' * 500 Label: text: root.text font_size: 50 text_size: self.width, None size_hint_y: None height: self.texture_size[1] ''') # Define scrollview class class ScrollableLabel(ScrollView): text = StringProperty('') # run the App runTouchApp(ScrollableLabel()) |
Output:

Recommended Posts:
- Python | Spinner widget in kivy
- Python | BoxLayout widget in Kivy
- Python | Carousel Widget In Kivy
- Python | Progress Bar widget in kivy
- Python | Checkbox widget in Kivy
- Python | Slider widget in Kivy
- Python | Add image widget in Kivy
- Python | Popup widget in Kivy
- Python | Textinput widget in kivy
- Python | Switch widget in Kivy
- Python | Spinner widget in Kivy using .kv file
- Python | Progressbar widget in kivy using .kv file
- Python | Carousel Widget In Kivy using .kv file
- Python | Popup widget in Kivy using .kv file
- Python | Switch widget in Kivy using .kv file
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



