mirror of https://github.com/kivy/kivy.git
Page:
A draggable scrollbar using a slider
Pages
A draggable scrollbar using a slider
AdBuddiz Android advertisements integration for Kivy apps
Advanced Graphics: In Progress
An example of background Twisted server running on Android
Android Background Services
Android SDK NDK Information
Android SDK NDK Informations
Android native embedded browser
Android style menu app skeleton
Background Service using P4A android.service
Batch installer for windows(KivyInstaller)
Breaking changes in Kivy
Building Portable Package
Button(s) in settings panel
Buttons in Settings panel
Community Guidelines
Connecting Kivy with Anaconda (OSX)
Contextual Menus
Contextual menus
Control alpha of all the children
Create source distribution release on PyPI
Creating a Release APK
Data driven variables with kivy properties
Debugging widget sizes
Deep Linking with iOS and Android
Delayed Work using Clock
Drag and Drop Widgets
Dragable Widget
Draggable Scalable Button
Editable ComboBox
Editable Label
Embedding a Carousel inside a TabbedPanel
GestureBox
Home
Implementing Android Adaptive Icons
KEP001: Instantiate things other than widgets from kv
Kivy 2.0 api breaks
Kivy Blogs and Blog Posts
Kivy Python 2 Support Timeline
Kivy Technical FAQ
Kv language preprocessing
Linking ScreenManager to a different Widget
List of Kivy Projects
Markup Summary
Menu on long touch
Migration guide from legacy garden packages
Moving kivy.garden.xxx to kivy_garden.xxx and kivy.deps.xxx to kivy_deps.xxx
On touch current widget
On touch on current widget
Packaging Kivy apps written in Python 3, targeting Windows using Nuitka
Pyjnius Vibrator Example
Release Checklist
Release notes for 1.10.0
Release notes for 1.11.0
Sample Gestures
Scaler for Retina screen
Scollable Options in Settings panel
Scrollable Label
Setting Up Kivy with various popular IDE's
Setting up Pycharm on OSX (older versions)
Setting up garden with Mac Ports
Setting up kivy with various popular IDE
Simple slider with value in label
Snippet template
Snippets awaiting moderation
Snippets
Starting Kivy App and Service on bootup on Android
Styling a Spinner and SpinnerOption in KV
Talks and tutorials
Theming Kivy
Tiled Maps & Tile Based Movement
Tiling the background of a widget with an image, pixel perfect
Ubuntu Touch
Updating widget content from a items list
User Snippets
Using Asynchronous programming inside a Kivy application
Using Buildozer on windows 10 using WSL
Viewport with fixed resolution autofit to window
Windows RT
Working with Python threads inside a Kivy application
rand0m app
wiki_proposed
7
A draggable scrollbar using a slider
E:V:A edited this page 2018-11-05 16:00:12 +00:00
Table of Contents
Summary
A Draggable Scrollbar using a Slider
- author: Crust3
- kivy: >= 1.5.1
Usage
To change the 'smoothness' of scrolling, change the 'step' of the slider
Files
DraggableScrollbar.py
#!python
import kivy
kivy.require('1.5.1')
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.stacklayout import StackLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.popup import Popup
from kivy.uix.scrollview import ScrollView
from kivy.uix.slider import Slider
from functools import partial
class ScrollApp(App):
def build(self):
popup = Popup(title='Draggable Scrollbar', size_hint=(0.8,1), auto_dismiss=False)
#this layout is the child widget for the main popup
layout1 = StackLayout(orientation='lr-bt')
#this button is a child of layout1
closebutton = Button(text='close', size_hint=(0.9,0.05))
closebutton.bind(on_press=popup.dismiss)
#another child of layout1 and this is the scrollview which will have a custom draggable scrollbar
scrlv = ScrollView(size_hint=(0.9,0.95))
#the last child of layout1 and this will act as the draggable scrollbar
s = Slider(min=0, max=1, value=25, orientation='vertical', step=0.01, size_hint=(0.1, 0.95))
scrlv.bind(scroll_y=partial(self.slider_change, s))
#what this does is, whenever the slider is dragged, it scrolls the previously added scrollview by the same amount the slider is dragged
s.bind(value=partial(self.scroll_change, scrlv))
layout2 = GridLayout(cols=4, size_hint_y=None)
layout2.bind(minimum_height=layout2.setter('height'))
for i in range(1, 301):
btn = Button(text=str(i), size_hint_y=None, height=60, valign='middle', font_size=12)
btn.text_size = (btn.size)
layout2.add_widget(btn)
scrlv.add_widget(layout2)
layout1.add_widget(closebutton)
layout1.add_widget(scrlv)
layout1.add_widget(s)
popup.content = layout1
popup.open()
def scroll_change(self, scrlv, instance, value):
scrlv.scroll_y = value
def slider_change(self, s, instance, value):
if value >= 0:
#this to avoid 'maximum recursion depth exceeded' error
s.value=value
if __name__ == '__main__':
ScrollApp().run()