Mercurial > libervia-desktop-kivy
comparison src/libs/garden/garden.contextmenu/examples/simple_app_menu.py @ 83:741a7d6d8c28
garden: added contextmenu
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 24 Dec 2016 14:16:58 +0100 |
parents | |
children | c439c271ecdd |
comparison
equal
deleted
inserted
replaced
82:4c6d56c069d9 | 83:741a7d6d8c28 |
---|---|
1 import kivy | |
2 from kivy.app import App | |
3 from kivy.lang import Builder | |
4 from kivy.logger import Logger | |
5 import logging | |
6 | |
7 kivy.require('1.9.0') | |
8 # Logger.setLevel(logging.DEBUG) | |
9 | |
10 import kivy.garden.contextmenu | |
11 | |
12 | |
13 kv = """ | |
14 FloatLayout: | |
15 id: layout | |
16 AppMenu: | |
17 id: app_menu | |
18 top: root.height | |
19 cancel_handler_widget: layout | |
20 | |
21 AppMenuTextItem: | |
22 text: "Menu #1" | |
23 ContextMenu: | |
24 ContextMenuTextItem: | |
25 text: "Item #11" | |
26 ContextMenuTextItem: | |
27 text: "Item #12" | |
28 AppMenuTextItem: | |
29 text: "Menu Menu Menu #2" | |
30 ContextMenu: | |
31 ContextMenuTextItem: | |
32 text: "Item #21" | |
33 ContextMenuTextItem: | |
34 text: "Item #22" | |
35 ContextMenuTextItem: | |
36 text: "ItemItemItem #23" | |
37 ContextMenuTextItem: | |
38 text: "Item #24" | |
39 ContextMenu: | |
40 ContextMenuTextItem: | |
41 text: "Item #241" | |
42 ContextMenuTextItem: | |
43 text: "Hello, World!" | |
44 on_release: app.say_hello(self.text) | |
45 ContextMenuTextItem: | |
46 text: "Item #243" | |
47 ContextMenuTextItem: | |
48 text: "Item #244" | |
49 ContextMenuTextItem: | |
50 text: "Item #5" | |
51 AppMenuTextItem: | |
52 text: "Menu Menu #3" | |
53 ContextMenu: | |
54 ContextMenuTextItem: | |
55 text: "SubMenu #31" | |
56 ContextMenuTextItem: | |
57 text: "SubMenu #32" | |
58 ContextMenuTextItem: | |
59 text: "SubMenu #33" | |
60 ContextMenuDivider: | |
61 ContextMenuTextItem: | |
62 text: "SubMenu #34" | |
63 AppMenuTextItem: | |
64 text: "Menu #4" | |
65 | |
66 Label: | |
67 pos: 10, 10 | |
68 text: "Left click anywhere outside the context menu to close it" | |
69 size_hint: None, None | |
70 size: self.texture_size | |
71 """ | |
72 | |
73 class MyApp(App): | |
74 | |
75 def build(self): | |
76 self.title = 'Simple app menu example' | |
77 return Builder.load_string(kv) | |
78 | |
79 def say_hello(self, text): | |
80 print(text) | |
81 self.root.ids['app_menu'].close_all() | |
82 | |
83 if __name__ == '__main__': | |
84 MyApp().run() |