Python + Kivy: Не работает DragDrop
Не могу понять почему не работает
import kivy
kivy.require('1.7.2') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.uix.button import Button
from kivy.uix.dropdown import DropDown
class DropBut(Button):
def __init__(self, **kwargs):
super(DropBut, self).__init__(**kwargs)
self.drop_list = None
self.drop_list = DropDown()
types = ['Item1', 'Item2', 'Item3', 'Item4', 'Item5', 'Item6']
for i in types:
btn = Button(text=i, size_hint=(0.5, 0.1), pos_hint = {'center_x': 0.5, 'center_y': 0.5})
btn.bind(on_release=lambda btn: self.drop_list.select(btn.text))
self.drop_list.add_widget(btn)
self.bind(on_release=self.drop_list.open)
self.drop_list.bind(on_select=lambda instance, x: setattr(self, 'text', x))
class dropdApp(App):
def build(self):
return DropBut()
if __name__ == '__main__':
dropdApp().run()