From 996d9ee5e582a0412eb68206f126358f33dcde9d Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Fri, 23 Feb 2024 09:58:34 -0700 Subject: [PATCH] docs(discussion): #443 --- examples/validation/discussion/443.py | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 examples/validation/discussion/443.py diff --git a/examples/validation/discussion/443.py b/examples/validation/discussion/443.py new file mode 100644 index 00000000..7c4d6116 --- /dev/null +++ b/examples/validation/discussion/443.py @@ -0,0 +1,68 @@ +import os +from trame.app import get_server +from trame.ui.vuetify3 import SinglePageLayout +from trame.widgets import trame, vuetify3 + +server = get_server() +server.client_type = os.environ.get("VUE_VERSION", "vue3") + +FILE_LISTING = [ + { + "text": "Hello.txt", + "value": "hello.txt", + "type": "File", + "prependIcon": "mdi-file-document-outline", + } +] + +PATH_HIERARCHY = [] + +server.state["menu_items"] = ["one", "two", "three"] + + +def on_click(e): + print(e) + + +def load_data(item): + print(item) + + +with SinglePageLayout(server) as layout: + layout.title.set_text("List Browser") + with layout.content: + trame.ListBrowser( + style="position: relative", + classes="pa-8", + location=("[100, 100]",), + handle_position="bottom", + filter=True, + list=("listing", FILE_LISTING), + path=("path", PATH_HIERARCHY), + click=(on_click, "[$event]"), + contextmenu=""" + $event.preventDefault(); + menuX = $event.clientX; + menuY = $event.clientY; + menuShow = true; + """, + ) + with vuetify3.VMenu( + v_model=("menuShow", False), + style=("{ position: 'absolute', left: `${menuX}px`, top: `${menuY}px`}",), + ) as menu: + print(menu) + with vuetify3.VList(): + with vuetify3.VListItem( + v_for="(item, i) in menu_items", + key="i", + value=["item"], + ): + vuetify3.VBtn( + "{{ item }}", + click=(load_data, "[item]"), + ) + + +if __name__ == "__main__": + server.start()