Change language

Python | Scrollview widget in kiwi

Kivy — it is a platform independent GUI tool in Python. Since it can run on Android, IOS, Linux, Windows, etc. It is mainly used to develop Android application, but that does not mean that it cannot be used in desktop applications.

Scroll view:

The ScrollView widget provides a scrollable / panning viewport that is clipped in the bounding scroll viewport.

The scroll view only accepts one child and applies a window to it accordingly with 2 properties:
1) scroll_x
2) scrool_y

The following properties are used to determine if an interaction is a scroll gesture:

  • scroll_distance : minimum distance to move, by default 20 pixels.
  • scroll_timeout : maximum time period, by default 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 

Code implementation:

# Program to explain how to use the scroll view in Kivy

 
# kivy module import

import kivy 

 
# Your application base class inherits from the application class.
# app: always refers to your application instance

fr om kivy.app import App 

 
# this limits the kivy version ie
# below this version you cannot
# use the application or software

kivy.require ( ’1.9.0’ )

 
# Label widget for rendering text

from kivy.uix.label import Label

 
# ScrollView widget provides a scrollable view

from kivy.uix.scrollview import ScrollView

 
# Property representing a string value

from kivy.properties import StringProperty

 
# Static main function that starts the application loop.

from kivy.base import runTouchApp

  
# Builder is the global Kivy instance used in
# widgets you can use to download others
# kv files in addition to the default files.

from kivy.lang import Builder

 

 
# Create a .kv file

Builder.load_string ( "" "

 
# Define the scroll type
"ScrollableLabel & gt ;:

  text:“ You are learning Kivy ”* 500

Tag:

text: root.text

  font_size: 50

  text_size: self.wi dth, None

size_hint_y: no

height: self.texture_size [1]

"" " )

 

 
# Define the scroll class

class ScrollableLabel (ScrollView):

text = StringProperty (’’)

 
# run the application
runTouchApp (ScrollableLabel ())

Output:

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method