mirror of https://github.com/kivy/kivy.git
Page:
Buttons in Settings panel
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
8
Buttons in Settings panel
Pekka Lehtikoski edited this page 2019-12-21 04:32:26 -05:00
Table of Contents
##Summary
- author: Thica
- kivy: >= 1.40
Hello all,
I would like to share a short snippet, if you need buttons in the settings dialog to trigger further actions:
Usage
- We need to have a new class based on SettingItem
#!python
from kivy.uix.settings import SettingItem
class SettingButtons(SettingItem):
def __init__(self, **kwargs):
self.register_event_type('on_release')
# For Python3 compatibility we need to drop the buttons keyword when calling super.
kw = kwargs.copy()
kw.pop('buttons', None)
super(SettingItem, self).__init__(**kw)
for aButton in kwargs["buttons"]:
oButton=Button(text=aButton['title'], font_size= '15sp')
oButton.ID=aButton['id']
self.add_widget(oButton)
oButton.bind (on_release=self.On_ButtonPressed)
def set_value(self, section, key, value):
# set_value normally reads the configparser values and runs on an error
# to do nothing here
return
def On_ButtonPressed(self,instance):
self.panel.settings.dispatch('on_config_change',self.panel.config, self.section, self.key, instance.ID)
- Register new class to settings widget
#!python
Setting = Settings()
Setting.register_type('buttons', SettingButtons)
- Define Buttons in the the json string
#!python
{"type": "buttons","title": "$lvar(565)","desc": "$lvar(566)","section": "$var(InterfaceConfigSection)","key": "configchangebuttons","buttons":[{"title":"Add","id":"button_add"},{"title":"Del","id":"button_delete"},{"title":"Rename","id":"button_rename"}]}
Some explanations: You can add more than one button: Title is the caption of the button, id will identify the button in the callback function
- Trigger your actions in On_ConfigChange(self,oSettings, oConfig, sSection, sKey, sValue), or On_ConfigChange(self, oConfig, sSection, sKey, sValue) if you use the App setting widget sValue will hold the id
Done!
##Comments ########
21.12.19/pekka: I also needed buttons with settings and used your code. It works well:)