не всплывает DropDown в kivy на Линукс
Решил поизучать kivy на примере Живой поиск kivy. Приложение сильно тупит, зависает во время живого поиска по базе данных
Но у меня не всплывает DropDown - просто не появляется
import kivy
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.widget import Widget
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.clock import Clock, _default_time as time
from kivy.properties import ListProperty
from multiprocessing.dummy import Pool # threads
from threading import Semaphore
import sqlite3
MAX_TIME = 1/60.
class TestApp(App):
data_items = []
data_sema = Semaphore(1)
def on_start(self):
self.threadpool = Pool(1)
self.db = self.threadpool.apply(sqlite3.connect, ('tikers.db',))
def on_data(self, data):
print('on_data')
dropdown = DropDown()
dropdown.bind(on_select=lambda instance, x: setattr(textinput, 'text', x))
dropdown.clear_widgets()
for line in data:
button = Button(text=line)
button.bind(on_press=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(button)
dropdown.open(self.textinput)
def get_data(self, text):
print('get_data', text)
c = self.db.cursor()
self.data_sema.acquire(blocking=True)
for row in c.execute('SELECT text FROM tiks WHERE text like ?', ( "%"+text+"%" ,)):
print(row)
App.get_running_app().data_items.append(row[0])
self.data_sema.release()
c.close()
print('end get_data')
def on_text(self, instance, value):
print('on_text', instance, value)
if value:
self.threadpool.apply_async(self.get_data, (value,),error_callback=print)
def consume(self, *args):
if self.data_items and time() < (Clock.get_time() + MAX_TIME):
print('consume')
self.data_sema.acquire(blocking=True)
self.on_data(self.data_items)
self.data_items.clear()
self.data_sema.release()
def build(self):
Clock.schedule_interval(self.consume, 0)
textinput = TextInput(text='', multiline=False)
textinput.bind(text=self.on_text)
self.textinput = textinput
return textinput
if __name__ == '__main__':
TestApp().run()