mirror of https://github.com/kivy/kivy.git
Page:
Editable ComboBox
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
3
Editable ComboBox
Akshay Arora edited this page 2023-08-01 12:02:34 +05:30
##Summary A DropDown attached to a TextInput
- author: Qua-non
- kivy: >= 2.2.1
Usage
To change the Options adjust the `options` in kv lang.
Files
####ComboEdit.py
from kivy.clock import Clock
from kivy.factory import Factory
from kivy.properties import ListProperty, StringProperty, ObjectProperty
from kivy.lang import Builder
Builder.load_string('''
<DDNButton@Button>
size_hint_y: None
height: dp(45)
''')
class ComboBox(Factory.TextInput):
options = ListProperty(('', ))
_options = ListProperty(('', ))
option_cls = ObjectProperty(Factory.DDNButton)
select = StringProperty('')
def __init__(self, **kw):
ddn = self.drop_down = Factory.DropDown()
ddn.bind(on_select=self.set_select)
super().__init__(**kw)
self.trigger_dropdown = Clock.create_trigger(self.drop_down_triggered, 1/2)
self.write_tab = False
self.multiline = False
def on_text_validate(self):
if not self._options:
return
# print(self.text, self._options[-1])
if not self.text in self._options[-1]:
return
self.set_select(self, self._options[-1])
def on_options(self, instance, value):
self._options = value
def on__options(self, instance, value):
ddn = self.drop_down
ddn.clear_widgets()
for option in value:
widg = self.option_cls(text=option)
widg.bind(on_release=lambda btn: ddn.select(btn.text))
ddn.add_widget(widg)
def set_select(self, *args):
# print('on_select', args)
if self.text != args[1]:
self.select = args[1]
self.text = args[1]
self.drop_down.dismiss()
def on_text(self, instance, value):
self.trigger_dropdown()
def drop_down_triggered(self, dt):
value = self.text
instance = self
# print(f'on_text {instance} "{value}"')
if value == '':
instance._options = self.options
return
else:
# print(f'on_text {instance} "{value}" on_else')
if value in self.options:
self.drop_down.pos = 0, -1000
return
r = re.compile(f".*{value}", re.IGNORECASE)
match = filter(r.match, instance.options)
#using a set to remove duplicates, if any.
instance._options = list(set(match))
# print(instance._options)
instance.drop_down.dismiss()
# print(instance.parent, instance.pos)
Clock.schedule_once(lambda dt: instance.drop_down.open(instance), .1)
def on_touch_up(self, touch):
# print('focus', value, self.text)
if touch.grab_current == self:
self.text = ''
self.drop_down.open(self)
# else:
# self.drop_down.dismiss()
if __name__ == '__main__':
from kivy.app import App
class MyApp(App):
def build(self):
return Builder.load_string('''
FloatLayout:
BoxLayout:
size_hint: .5, None
pos: 0, root.top - self.height
ComboBox:
options: ['Hello', 'World']
ComboBox:
options: '99 bottles of beer on the wall , Tito hit of them down from the wall , 98 bottles of beer!'.split(' ')
Button
''')
MyApp().run()
##Comments Add your comments here