Mercurial > libervia-desktop-kivy
annotate src/libs/garden/garden.contextmenu/examples/simple_app_menu.py @ 115:e0c41f209c28
CagouWidget: instances can now add their own extra widgets in header with headerInputAddExtra
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jan 2017 20:39:29 +0100 |
parents | c439c271ecdd |
children |
rev | line source |
---|---|
83 | 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 kv = """ | |
13 FloatLayout: | |
14 id: layout | |
15 AppMenu: | |
16 id: app_menu | |
17 top: root.height | |
18 cancel_handler_widget: layout | |
19 | |
20 AppMenuTextItem: | |
21 text: "Menu #1" | |
22 ContextMenu: | |
23 ContextMenuTextItem: | |
24 text: "Item #11" | |
25 ContextMenuTextItem: | |
26 text: "Item #12" | |
27 AppMenuTextItem: | |
28 text: "Menu Menu Menu #2" | |
29 ContextMenu: | |
30 ContextMenuTextItem: | |
31 text: "Item #21" | |
32 ContextMenuTextItem: | |
33 text: "Item #22" | |
34 ContextMenuTextItem: | |
35 text: "ItemItemItem #23" | |
36 ContextMenuTextItem: | |
37 text: "Item #24" | |
38 ContextMenu: | |
39 ContextMenuTextItem: | |
40 text: "Item #241" | |
41 ContextMenuTextItem: | |
42 text: "Hello, World!" | |
43 on_release: app.say_hello(self.text) | |
44 ContextMenuTextItem: | |
45 text: "Item #243" | |
46 ContextMenuTextItem: | |
47 text: "Item #244" | |
48 ContextMenuTextItem: | |
49 text: "Item #5" | |
50 AppMenuTextItem: | |
51 text: "Menu Menu #3" | |
52 ContextMenu: | |
53 ContextMenuTextItem: | |
54 text: "SubMenu #31" | |
55 ContextMenuTextItem: | |
56 text: "SubMenu #32" | |
57 ContextMenuTextItem: | |
58 text: "SubMenu #33" | |
59 ContextMenuDivider: | |
60 ContextMenuTextItem: | |
61 text: "SubMenu #34" | |
62 AppMenuTextItem: | |
63 text: "Menu #4" | |
64 | |
65 Label: | |
66 pos: 10, 10 | |
67 text: "Left click anywhere outside the context menu to close it" | |
68 size_hint: None, None | |
69 size: self.texture_size | |
70 """ | |
71 | |
113
c439c271ecdd
core (notifications), CagouWidget: a backround rectangle is drawned behind drop boxes
Goffi <goffi@goffi.org>
parents:
83
diff
changeset
|
72 |
83 | 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() |