|
|
@ -6,6 +6,7 @@ from kivy.animation import Animation |
|
|
|
from kivy.uix.floatlayout import FloatLayout |
|
|
|
from kivy.lang import Builder |
|
|
|
from kivy.factory import Factory |
|
|
|
from kivy.clock import Clock |
|
|
|
|
|
|
|
Builder.load_string(''' |
|
|
|
<MenuItem@Button> |
|
|
@ -33,6 +34,7 @@ class MenuItem(Factory.Button): |
|
|
|
pass |
|
|
|
|
|
|
|
class ContextMenu(Bubble): |
|
|
|
|
|
|
|
def __init__(self, obj, action_list): |
|
|
|
Bubble.__init__(self) |
|
|
|
self.obj = obj |
|
|
@ -40,7 +42,11 @@ class ContextMenu(Bubble): |
|
|
|
l = MenuItem() |
|
|
|
l.text = k |
|
|
|
def func(f=v): |
|
|
|
f(obj) |
|
|
|
if self.parent: self.parent.hide_menu() |
|
|
|
Clock.schedule_once(lambda dt: self.hide(), 0.1) |
|
|
|
Clock.schedule_once(lambda dt: f(obj), 0.15) |
|
|
|
l.on_release = func |
|
|
|
self.ids.buttons.add_widget(l) |
|
|
|
|
|
|
|
def hide(self): |
|
|
|
if self.parent: |
|
|
|
self.parent.hide_menu() |
|
|
|