neutralino-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neutralino/__init__.py +88 -0
- neutralino/_catalog.py +297 -0
- neutralino/_data/LICENSE.neutralino-js-client +21 -0
- neutralino/_data/LICENSE.neutralinojs +1066 -0
- neutralino/_data/docs/cli.md +315 -0
- neutralino/_data/docs/custom-components.md +107 -0
- neutralino/_data/docs/custom-frontends.md +80 -0
- neutralino/_data/docs/desktop-helpers.md +296 -0
- neutralino/_data/docs/guide.md +131 -0
- neutralino/_data/docs/llms-full.txt +3921 -0
- neutralino/_data/docs/llms.txt +43 -0
- neutralino/_data/docs/manifests/components.json +20128 -0
- neutralino/_data/docs/manifests/examples.json +52 -0
- neutralino/_data/docs/manifests/native.json +3024 -0
- neutralino/_data/docs/manifests/schema.json +43 -0
- neutralino/_data/docs/manual-checklist.md +189 -0
- neutralino/_data/docs/packaging.md +252 -0
- neutralino/_data/docs/performance.md +15 -0
- neutralino/_data/docs/platforms.md +15 -0
- neutralino/_data/docs/reference/components.md +1685 -0
- neutralino/_data/docs/reference/native.md +148 -0
- neutralino/_data/docs/security.md +60 -0
- neutralino/_data/docs/ui.md +249 -0
- neutralino/_data/docs/updates.md +366 -0
- neutralino/_data/examples/README.md +6 -0
- neutralino/_data/examples/crud/README.md +36 -0
- neutralino/_data/examples/crud/app.py +243 -0
- neutralino/_data/examples/dashboard/README.md +36 -0
- neutralino/_data/examples/dashboard/app.py +367 -0
- neutralino/_data/examples/editor/README.md +35 -0
- neutralino/_data/examples/editor/app.py +190 -0
- neutralino/_data/examples/file-manager/README.md +40 -0
- neutralino/_data/examples/file-manager/app.py +120 -0
- neutralino/_data/examples/file-manager/frontend/index.html +20 -0
- neutralino/_data/examples/file-manager/frontend/main.js +55 -0
- neutralino/_data/examples/file-manager/frontend/neutralino.js +1 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/file-manager/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/file-manager/frontend/style.css +4 -0
- neutralino/_data/examples/hybrid/README.md +48 -0
- neutralino/_data/examples/hybrid/app.py +80 -0
- neutralino/_data/examples/hybrid/components/counter.mjs +37 -0
- neutralino/_data/examples/hybrid/components/widget.mjs +23 -0
- neutralino/_data/examples/hybrid/styles.css +21 -0
- neutralino/_data/examples/hybrid/widget/package.json +20 -0
- neutralino/_data/examples/hybrid/widget/src/Widget.jsx +25 -0
- neutralino/_data/examples/hybrid/widget/vite.config.mjs +19 -0
- neutralino/_data/examples/monitor/README.md +36 -0
- neutralino/_data/examples/monitor/app.py +375 -0
- neutralino/_data/examples/react/README.md +90 -0
- neutralino/_data/examples/react/app.py +68 -0
- neutralino/_data/examples/react/frontend/.gitignore +5 -0
- neutralino/_data/examples/react/frontend/index.html +17 -0
- neutralino/_data/examples/react/frontend/package-lock.json +1232 -0
- neutralino/_data/examples/react/frontend/package.json +25 -0
- neutralino/_data/examples/react/frontend/scripts/prepare-bridge.mjs +49 -0
- neutralino/_data/examples/react/frontend/src/App.tsx +157 -0
- neutralino/_data/examples/react/frontend/src/backend.ts +21 -0
- neutralino/_data/examples/react/frontend/src/calls.test.ts +206 -0
- neutralino/_data/examples/react/frontend/src/calls.ts +306 -0
- neutralino/_data/examples/react/frontend/src/globals.d.ts +14 -0
- neutralino/_data/examples/react/frontend/src/hooks.ts +45 -0
- neutralino/_data/examples/react/frontend/src/main.tsx +13 -0
- neutralino/_data/examples/react/frontend/src/styles.css +11 -0
- neutralino/_data/examples/react/frontend/tsconfig.json +18 -0
- neutralino/_data/examples/react/frontend/vite.config.ts +9 -0
- neutralino/_data/examples/settings/README.md +38 -0
- neutralino/_data/examples/settings/app.py +440 -0
- neutralino/_data/examples/updater/.gitignore +2 -0
- neutralino/_data/examples/updater/README.md +82 -0
- neutralino/_data/examples/updater/app.py +160 -0
- neutralino/_data/examples/updater/app.toml +21 -0
- neutralino/_data/examples/updater/demo.py +107 -0
- neutralino/_data/examples/updater/requirements.txt +2 -0
- neutralino/_data/examples/updater/sources/github-private.toml +21 -0
- neutralino/_data/examples/updater/sources/github-public.toml +21 -0
- neutralino/_data/examples/vanilla/README.md +35 -0
- neutralino/_data/examples/vanilla/app.py +46 -0
- neutralino/_data/examples/vanilla/frontend/index.html +17 -0
- neutralino/_data/examples/vanilla/frontend/main.js +29 -0
- neutralino/_data/examples/vanilla/frontend/neutralino.js +1 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.d.ts +207 -0
- neutralino/_data/examples/vanilla/frontend/python-bridge.mjs +854 -0
- neutralino/_data/examples/vanilla/frontend/style.css +4 -0
- neutralino/_data/explorer/app.py +1328 -0
- neutralino/_data/explorer/catalogue.json +48179 -0
- neutralino/_data/explorer/explorer_previews.py +247 -0
- neutralino/_data/explorer/sources/native/always_on_top.py +55 -0
- neutralino/_data/explorer/sources/native/binary.py +125 -0
- neutralino/_data/explorer/sources/native/borderless.py +99 -0
- neutralino/_data/explorer/sources/native/broadcast.py +90 -0
- neutralino/_data/explorer/sources/native/config.py +78 -0
- neutralino/_data/explorer/sources/native/controls.py +140 -0
- neutralino/_data/explorer/sources/native/directory.py +163 -0
- neutralino/_data/explorer/sources/native/displays.py +75 -0
- neutralino/_data/explorer/sources/native/env.py +98 -0
- neutralino/_data/explorer/sources/native/events.py +124 -0
- neutralino/_data/explorer/sources/native/exec_command.py +79 -0
- neutralino/_data/explorer/sources/native/folder.py +70 -0
- neutralino/_data/explorer/sources/native/icon_badge.py +101 -0
- neutralino/_data/explorer/sources/native/image.py +119 -0
- neutralino/_data/explorer/sources/native/lifecycle.py +99 -0
- neutralino/_data/explorer/sources/native/locale.py +70 -0
- neutralino/_data/explorer/sources/native/main_menu.py +103 -0
- neutralino/_data/explorer/sources/native/message_box.py +101 -0
- neutralino/_data/explorer/sources/native/mouse.py +70 -0
- neutralino/_data/explorer/sources/native/multi_window.py +134 -0
- neutralino/_data/explorer/sources/native/notification.py +74 -0
- neutralino/_data/explorer/sources/native/open_external.py +81 -0
- neutralino/_data/explorer/sources/native/open_file.py +102 -0
- neutralino/_data/explorer/sources/native/paths.py +77 -0
- neutralino/_data/explorer/sources/native/print_snapshot.py +84 -0
- neutralino/_data/explorer/sources/native/read_write.py +192 -0
- neutralino/_data/explorer/sources/native/resources.py +110 -0
- neutralino/_data/explorer/sources/native/save_file.py +101 -0
- neutralino/_data/explorer/sources/native/server_mount.py +106 -0
- neutralino/_data/explorer/sources/native/sound.py +84 -0
- neutralino/_data/explorer/sources/native/spawn_process.py +128 -0
- neutralino/_data/explorer/sources/native/states.py +122 -0
- neutralino/_data/explorer/sources/native/stats_permissions.py +147 -0
- neutralino/_data/explorer/sources/native/storage.py +108 -0
- neutralino/_data/explorer/sources/native/system_info.py +115 -0
- neutralino/_data/explorer/sources/native/text.py +133 -0
- neutralino/_data/explorer/sources/native/trash.py +98 -0
- neutralino/_data/explorer/sources/native/tray.py +109 -0
- neutralino/_data/explorer/sources/native/watcher.py +167 -0
- neutralino/_data/explorer/sources/patterns/content_blocks.py +119 -0
- neutralino/_data/explorer/sources/patterns/dynamic_dashboard.py +121 -0
- neutralino/_data/explorer/sources/patterns/dynamic_form.py +120 -0
- neutralino/_data/explorer/sources/patterns/dynamic_table.py +109 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.mjs +24 -0
- neutralino/_data/explorer/sources/patterns/error_reporting.py +124 -0
- neutralino/_data/explorer/sources/patterns/errors_timeouts.py +108 -0
- neutralino/_data/explorer/sources/patterns/feature_flags.py +99 -0
- neutralino/_data/explorer/sources/patterns/file_drop.py +126 -0
- neutralino/_data/explorer/sources/patterns/http_from_python.py +152 -0
- neutralino/_data/explorer/sources/patterns/keyboard_shortcuts.py +153 -0
- neutralino/_data/explorer/sources/patterns/live_config_reload.py +160 -0
- neutralino/_data/explorer/sources/patterns/logging.py +184 -0
- neutralino/_data/explorer/sources/patterns/long_tasks.py +121 -0
- neutralino/_data/explorer/sources/patterns/multi_window_sync.py +68 -0
- neutralino/_data/explorer/sources/patterns/navigation_from_backend.py +109 -0
- neutralino/_data/explorer/sources/patterns/onboarding.py +123 -0
- neutralino/_data/explorer/sources/patterns/optimistic_updates.py +89 -0
- neutralino/_data/explorer/sources/patterns/persistence.py +114 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.mjs +10 -0
- neutralino/_data/explorer/sources/patterns/python_calls_page.py +64 -0
- neutralino/_data/explorer/sources/patterns/python_push.py +84 -0
- neutralino/_data/explorer/sources/patterns/recurring_events.py +114 -0
- neutralino/_data/explorer/sources/patterns/roles_permissions.py +104 -0
- neutralino/_data/explorer/sources/patterns/scheduled_jobs.py +194 -0
- neutralino/_data/explorer/sources/patterns/settings_page.py +165 -0
- neutralino/_data/explorer/sources/patterns/sqlite.py +181 -0
- neutralino/_data/explorer/sources/patterns/streaming.py +102 -0
- neutralino/_data/explorer/sources/patterns/texts_i18n.py +81 -0
- neutralino/_data/explorer/sources/patterns/theme_from_backend.py +86 -0
- neutralino/_data/explorer/sources/patterns/updater.py +232 -0
- neutralino/_data/explorer/sources/workspace/calendar/app.py +547 -0
- neutralino/_data/explorer/sources/workspace/customers/app.py +467 -0
- neutralino/_data/explorer/sources/workspace/dashboard/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/dashboard/app.py +367 -0
- neutralino/_data/explorer/sources/workspace/documents/app.py +511 -0
- neutralino/_data/explorer/sources/workspace/inbox/app.py +439 -0
- neutralino/_data/explorer/sources/workspace/orders/app.py +491 -0
- neutralino/_data/explorer/sources/workspace/reports/app.py +386 -0
- neutralino/_data/explorer/sources/workspace/settings/README.md +38 -0
- neutralino/_data/explorer/sources/workspace/settings/app.py +440 -0
- neutralino/_data/explorer/sources/workspace/system/README.md +36 -0
- neutralino/_data/explorer/sources/workspace/system/app.py +375 -0
- neutralino/_data/explorer/sources/workspace/tasks/app.py +462 -0
- neutralino/_data/renderer/LICENSES/@babel__runtime@7.29.17/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/@codemirror__autocomplete@6.20.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__commands@6.11.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-css@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-html@6.4.12/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-javascript@6.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-json@6.0.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-markdown@6.5.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-python@6.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-sql@6.10.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__lang-yaml@6.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__language@6.13.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__search@6.7.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__state@6.7.6/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@codemirror__view@6.44.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__accessibility@3.1.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__core@6.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__sortable@10.0.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@dnd-kit__utilities@3.2.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@emoji-mart__data@1.2.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__core@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__dom@1.8.0/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react-dom@2.1.9/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__react@0.27.20/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@floating-ui__utils@0.2.12/LICENSE +20 -0
- neutralino/_data/renderer/LICENSES/@lezer__common@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__css@1.3.9/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__highlight@1.2.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__html@1.3.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__javascript@1.5.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__json@1.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__lr@1.4.13/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__markdown@1.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__python@1.1.21/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@lezer__yaml@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__carousel@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__charts@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__code-highlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__core@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dates@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__dropzone@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__emoji@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__hooks@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__lightbox@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__notifications@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__nprogress@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__schedule@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__spotlight@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__store@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@mantine__tiptap@9.8.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@marijn__find-cluster-break@1.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@reduxjs__toolkit@2.16.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tabler__icons-react@3.55.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__react-virtual@3.14.32/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tanstack__virtual-core@3.19.17/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__core@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-blockquote@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-bold@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code-block@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-code@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-document@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-hard-break@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-heading@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-horizontal-rule@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-italic@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-link@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-list@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-paragraph@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-strike@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-text@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extension-underline@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__extensions@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__react@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/@tiptap__starter-kit@3.35.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/attr-accept@4.0.1/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/clsx@2.1.1/license +9 -0
- neutralino/_data/renderer/LICENSES/crelt@1.0.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/d3-array@3.2.5/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-color@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-format@3.1.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-interpolate@3.0.2/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-path@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-scale@4.0.3/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-shape@3.2.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time-format@4.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/d3-time@3.1.1/LICENSE +13 -0
- neutralino/_data/renderer/LICENSES/dayjs@1.11.23/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/decimal.js-light@2.5.1/LICENCE.md +23 -0
- neutralino/_data/renderer/LICENSES/diff@9.0.0/LICENSE +29 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE +202 -0
- neutralino/_data/renderer/LICENSES/dompurify@3.5.1/LICENSE-MPL +373 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-react@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel-reactive-utils@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/embla-carousel@8.6.0/MIT-embla-carousel.txt +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/es-toolkit@1.53.2/NOTICE +39 -0
- neutralino/_data/renderer/LICENSES/eventemitter3@5.0.4/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/fast-equals@5.4.7/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/file-selector@5.0.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/get-nonce@1.0.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/immer@11.2.14/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/linkifyjs@4.4.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/marked@18.4.0/LICENSE +44 -0
- neutralino/_data/renderer/LICENSES/neutralino.js@6.11.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/orderedmap@2.1.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/packages.json +1838 -0
- neutralino/_data/renderer/LICENSES/prosemirror-commands@1.7.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-dropcursor@1.8.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-gapcursor@1.4.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-history@1.5.2/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-keymap@1.2.3/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-model@1.25.13/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-schema-list@1.6.1/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-state@1.4.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-transform@1.12.7/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/prosemirror-view@1.44.0/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/react-dom@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-dropzone@20.1.4/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/react-is@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-number-format@5.4.5/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-redux@9.3.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll-bar@2.3.8/MIT-react-remove-scroll-bar.txt +21 -0
- neutralino/_data/renderer/LICENSES/react-remove-scroll@2.7.2/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-style-singleton@2.2.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/react-transition-group@4.4.5/LICENSE +30 -0
- neutralino/_data/renderer/LICENSES/react@19.3.1/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/recharts@3.11.3/LICENSE +22 -0
- neutralino/_data/renderer/LICENSES/redux-thunk@3.1.0/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/redux@5.0.1/LICENSE.md +21 -0
- neutralino/_data/renderer/LICENSES/reselect@5.2.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/rolldown@1.3.4/LICENSE +25 -0
- neutralino/_data/renderer/LICENSES/rope-sequence@1.3.4/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/rrule@2.8.1/LICENCE +65 -0
- neutralino/_data/renderer/LICENSES/scheduler@0.28.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/style-mod@4.1.5/LICENSE +19 -0
- neutralino/_data/renderer/LICENSES/tiny-invariant@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/tslib@2.9.1/LICENSE.txt +12 -0
- neutralino/_data/renderer/LICENSES/use-callback-ref@1.3.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sidecar@1.1.3/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/use-sync-external-store@1.7.0/LICENSE +21 -0
- neutralino/_data/renderer/LICENSES/victory-vendor@38.1.1/LICENSE.txt +150 -0
- neutralino/_data/renderer/LICENSES/vite@8.4.1/LICENSE.md +2320 -0
- neutralino/_data/renderer/LICENSES/w3c-keyname@2.2.8/LICENSE +19 -0
- neutralino/_data/renderer/assets/IconGripVertical-BlJrWVuo.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DniHwTLK.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-Du0h7lB-.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CCe_blv1.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-CinrNxVJ.js +2 -0
- neutralino/_data/renderer/assets/css-CMUk25uq.js +1 -0
- neutralino/_data/renderer/assets/dist-70Le0T2N.js +1 -0
- neutralino/_data/renderer/assets/dist-BCHbQlae.js +11 -0
- neutralino/_data/renderer/assets/dist-BXts23GT.js +1 -0
- neutralino/_data/renderer/assets/dist-D2RX2UgP.js +23 -0
- neutralino/_data/renderer/assets/dist-DikJK2lp.js +1 -0
- neutralino/_data/renderer/assets/dist-acbbRM1z.js +1 -0
- neutralino/_data/renderer/assets/dnd-DaaaVala.js +5 -0
- neutralino/_data/renderer/assets/dropzone-CeqF5SZx.js +1 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-CbyYjwMN.js +1 -0
- neutralino/_data/renderer/assets/emoji-BfRPfoVw.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-C5ZYjSBQ.js +82 -0
- neutralino/_data/renderer/assets/highlight-CB6hGb5A.js +3 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/html-Dad3kwIa.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-X3Kr0nh-.js +1 -0
- neutralino/_data/renderer/assets/index-CU0HB-J7.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-BQb8vpw3.js +1 -0
- neutralino/_data/renderer/assets/json-BCFmxlML.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BHtgbsUV.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-DSuAylvy.js +5 -0
- neutralino/_data/renderer/assets/markdown-DjaNWMgH.js +77 -0
- neutralino/_data/renderer/assets/python-pdbIAveZ.js +9 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/richtext-Z6fG9G2_.js +137 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-knlyJw_A.js +1 -0
- neutralino/_data/renderer/assets/sql-DLoQFEde.js +2 -0
- neutralino/_data/renderer/assets/with-selector-BOM9_OlN.js +1 -0
- neutralino/_data/renderer/assets/yaml-BJNzokSe.js +1 -0
- neutralino/_data/renderer/index.html +22 -0
- neutralino/_data/renderer/manifest.json +202 -0
- neutralino/_data/renderer/neutralino.js +1 -0
- neutralino/_data/renderer/shared/mantine-core.mjs +5 -0
- neutralino/_data/renderer/shared/mantine-hooks.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom-client.mjs +5 -0
- neutralino/_data/renderer/shared/react-dom.mjs +6 -0
- neutralino/_data/renderer/shared/react-jsx-runtime.mjs +5 -0
- neutralino/_data/renderer/shared/react.mjs +6 -0
- neutralino/_data/skills/README.md +6 -0
- neutralino/_data/skills/neutralino-app-patterns/SKILL.md +101 -0
- neutralino/_data/skills/neutralino-app-patterns/references/dashboards-and-background-work.md +55 -0
- neutralino/_data/skills/neutralino-app-patterns/references/storage-and-settings.md +57 -0
- neutralino/_data/skills/neutralino-app-patterns/references/tables-and-crud.md +81 -0
- neutralino/_data/skills/neutralino-frontend/SKILL.md +121 -0
- neutralino/_data/skills/neutralino-frontend/references/bridge.md +63 -0
- neutralino/_data/skills/neutralino-frontend/references/custom-components.md +84 -0
- neutralino/_data/skills/neutralino-frontend/references/frameworks.md +61 -0
- neutralino/_data/skills/neutralino-maintenance/SKILL.md +85 -0
- neutralino/_data/skills/neutralino-maintenance/references/platforms-and-gates.md +35 -0
- neutralino/_data/skills/neutralino-maintenance/references/records.md +38 -0
- neutralino/_data/skills/neutralino-maintenance/references/review-process.md +36 -0
- neutralino/_data/skills/neutralino-native/SKILL.md +107 -0
- neutralino/_data/skills/neutralino-native/references/api-conventions.md +72 -0
- neutralino/_data/skills/neutralino-native/references/desktop-helpers.md +53 -0
- neutralino/_data/skills/neutralino-native/references/permissions-windows.md +53 -0
- neutralino/_data/skills/neutralino-packaging/SKILL.md +99 -0
- neutralino/_data/skills/neutralino-packaging/references/build-layout.md +51 -0
- neutralino/_data/skills/neutralino-packaging/references/managed-install.md +59 -0
- neutralino/_data/skills/neutralino-packaging/references/templates-and-config.md +63 -0
- neutralino/_data/skills/neutralino-python/SKILL.md +109 -0
- neutralino/_data/skills/neutralino-python/references/architecture.md +53 -0
- neutralino/_data/skills/neutralino-python/references/cli.md +60 -0
- neutralino/_data/skills/neutralino-python/references/platforms-security.md +44 -0
- neutralino/_data/skills/neutralino-rpc/SKILL.md +114 -0
- neutralino/_data/skills/neutralino-rpc/references/errors-and-limits.md +44 -0
- neutralino/_data/skills/neutralino-rpc/references/expose-and-context.md +74 -0
- neutralino/_data/skills/neutralino-rpc/references/streams-and-cancellation.md +53 -0
- neutralino/_data/skills/neutralino-ui/SKILL.md +115 -0
- neutralino/_data/skills/neutralino-ui/references/components-and-tree.md +74 -0
- neutralino/_data/skills/neutralino-ui/references/state-forms-events.md +85 -0
- neutralino/_data/skills/neutralino-ui/references/themes-profiles-assets.md +105 -0
- neutralino/_data/skills/neutralino-updates/SKILL.md +94 -0
- neutralino/_data/skills/neutralino-updates/references/config-and-api.md +80 -0
- neutralino/_data/skills/neutralino-updates/references/releases-and-install.md +77 -0
- neutralino/_data/skills/neutralino-updates/references/security-rollback.md +48 -0
- neutralino/_data/ui/contracts.json +32927 -0
- neutralino/_data/ui/emoji.json +1 -0
- neutralino/_data/upstream-lock.json +97 -0
- neutralino/_managed.py +1099 -0
- neutralino/_paths.py +220 -0
- neutralino/_platform.py +150 -0
- neutralino/_scaffold.py +344 -0
- neutralino/api/_base.py +99 -0
- neutralino/api/_custom.py +1350 -0
- neutralino/api/_dec.py +21 -0
- neutralino/api/_enc.py +80 -0
- neutralino/api/app.py +119 -0
- neutralino/api/clipboard.py +101 -0
- neutralino/api/computer.py +261 -0
- neutralino/api/custom.py +36 -0
- neutralino/api/debug.py +41 -0
- neutralino/api/extensions.py +57 -0
- neutralino/api/filesystem.py +633 -0
- neutralino/api/net.py +22 -0
- neutralino/api/os.py +508 -0
- neutralino/api/resources.py +124 -0
- neutralino/api/server.py +66 -0
- neutralino/api/storage.py +98 -0
- neutralino/api/types.py +342 -0
- neutralino/api/updater.py +22 -0
- neutralino/api/window.py +397 -0
- neutralino/application.py +1260 -0
- neutralino/bundle.py +187 -0
- neutralino/cli.py +629 -0
- neutralino/client.py +496 -0
- neutralino/config.py +671 -0
- neutralino/devtools.py +1973 -0
- neutralino/errors.py +142 -0
- neutralino/events.py +579 -0
- neutralino/execution.py +293 -0
- neutralino/extension.py +134 -0
- neutralino/frontend/python-bridge.d.ts +207 -0
- neutralino/frontend/python-bridge.mjs +854 -0
- neutralino/protocol.py +456 -0
- neutralino/py.typed +0 -0
- neutralino/rpc.py +1625 -0
- neutralino/runtime.py +591 -0
- neutralino/supervisor.py +866 -0
- neutralino/sync_client.py +376 -0
- neutralino/templates/default/app.py +32 -0
- neutralino/templates/default/frontend/app.js +28 -0
- neutralino/templates/default/frontend/index.html +26 -0
- neutralino/templates/default/frontend/neutralino.js +1 -0
- neutralino/templates/default/frontend/styles.css +8 -0
- neutralino/templates/default/gitignore.txt +3 -0
- neutralino/templates/default/neutralino.config.json +25 -0
- neutralino/templates/hybrid/README.md +17 -0
- neutralino/templates/hybrid/app.py +49 -0
- neutralino/templates/hybrid/components/counter.mjs +37 -0
- neutralino/templates/hybrid/styles.css +21 -0
- neutralino/templates/python-ui/README.md +15 -0
- neutralino/templates/python-ui/app.py +44 -0
- neutralino/templates/python-ui/gitignore.txt +3 -0
- neutralino/templates/python-ui/requirements.txt +4 -0
- neutralino/templates/react/README.md +28 -0
- neutralino/templates/react/app.py +52 -0
- neutralino/templates/react/components/widget.mjs +23 -0
- neutralino/templates/react/widget/package.json +20 -0
- neutralino/templates/react/widget/src/Widget.jsx +25 -0
- neutralino/templates/react/widget/vite.config.mjs +19 -0
- neutralino/transport.py +661 -0
- neutralino/types.py +93 -0
- neutralino/ui/__init__.py +139 -0
- neutralino/ui/_app.py +1529 -0
- neutralino/ui/_assets.py +407 -0
- neutralino/ui/_bases.py +1210 -0
- neutralino/ui/_behaviours.py +1066 -0
- neutralino/ui/_charts.py +732 -0
- neutralino/ui/_component.py +882 -0
- neutralino/ui/_dates.py +168 -0
- neutralino/ui/_desktop.py +879 -0
- neutralino/ui/_events.py +192 -0
- neutralino/ui/_filters.py +427 -0
- neutralino/ui/_forms.py +282 -0
- neutralino/ui/_protocol.py +201 -0
- neutralino/ui/_schedule.py +543 -0
- neutralino/ui/_security.py +106 -0
- neutralino/ui/_session.py +969 -0
- neutralino/ui/_state.py +199 -0
- neutralino/ui/_tables.py +256 -0
- neutralino/ui/_theme.py +154 -0
- neutralino/ui/blocks/__init__.py +19 -0
- neutralino/ui/blocks/_data.py +2239 -0
- neutralino/ui/blocks/_interactive.py +622 -0
- neutralino/ui/blocks/_layout.py +2967 -0
- neutralino/ui/components/__init__.py +81 -0
- neutralino/ui/components/_dates.py +879 -0
- neutralino/ui/components/_editors.py +217 -0
- neutralino/ui/components/_extensions.py +790 -0
- neutralino/ui/components/_extras.py +303 -0
- neutralino/ui/components/_generated.py +30565 -0
- neutralino/ui/components/_types.py +17 -0
- neutralino/ui/schema.py +824 -0
- neutralino/ui/validators.py +362 -0
- neutralino/updates/__init__.py +96 -0
- neutralino/updates/_http.py +320 -0
- neutralino/updates/_layout.py +762 -0
- neutralino/updates/archive.py +216 -0
- neutralino/updates/config.py +256 -0
- neutralino/updates/errors.py +97 -0
- neutralino/updates/install.sh.in +201 -0
- neutralino/updates/launcher.py +18 -0
- neutralino/updates/manager.py +808 -0
- neutralino/updates/manifest.py +196 -0
- neutralino/updates/release.py +314 -0
- neutralino/updates/semver.py +84 -0
- neutralino/updates/sources.py +392 -0
- neutralino/windows.py +316 -0
- neutralino_python-0.1.0.dist-info/METADATA +121 -0
- neutralino_python-0.1.0.dist-info/RECORD +521 -0
- neutralino_python-0.1.0.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Server-driven dashboard: validated schema widgets in real dashboard blocks.
|
|
2
|
+
|
|
3
|
+
The page layout is ``ui.blocks.DashboardGrid`` and the headline numbers are
|
|
4
|
+
``ui.blocks.StatsCard`` blocks updated from Python. The chart, table and
|
|
5
|
+
header widgets come from validated plain-data schemas (``ui.schema``) whose
|
|
6
|
+
``key``s let Python update them live. A widget type the application does not
|
|
7
|
+
know ("Gauge" from a newer server) is shown as a neutral placeholder instead
|
|
8
|
+
of failing the dashboard. The Refresh button is bound to a *registered*
|
|
9
|
+
action.
|
|
10
|
+
|
|
11
|
+
Run: ``uv run python examples/patterns/dynamic_dashboard.py``
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import math
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
from neutralino import ui
|
|
20
|
+
|
|
21
|
+
HEADER: dict[str, Any] = {
|
|
22
|
+
"type": "Group",
|
|
23
|
+
"props": {"justify": "space-between"},
|
|
24
|
+
"children": [
|
|
25
|
+
{"type": "Title", "props": {"text": "Operations", "order": 2}},
|
|
26
|
+
{
|
|
27
|
+
"type": "Button",
|
|
28
|
+
"props": {"label": "Refresh"},
|
|
29
|
+
"key": "refresh",
|
|
30
|
+
"on": {"click": "dashboard.refresh"},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
CHART: dict[str, Any] = {
|
|
36
|
+
"type": "LineChart",
|
|
37
|
+
"key": "cpu",
|
|
38
|
+
"props": {
|
|
39
|
+
"data_key": "t",
|
|
40
|
+
"series": [{"name": "cpu", "color": "blue.6"}],
|
|
41
|
+
"max_points": 60,
|
|
42
|
+
"h": 200,
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
UNKNOWN: dict[str, Any] = {"type": "Gauge", "props": {"value": 3}} # not known to this app
|
|
47
|
+
|
|
48
|
+
TABLE: dict[str, Any] = {
|
|
49
|
+
"type": "Table",
|
|
50
|
+
"key": "top",
|
|
51
|
+
"props": {"data": {"head": ["Service", "Latency ms"], "body": []}, "striped": True},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
STATS = (("users", "Active users"), ("orders", "Orders today"), ("errors", "Errors"))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Dashboard:
|
|
58
|
+
def __init__(
|
|
59
|
+
self,
|
|
60
|
+
refs: dict[str, ui.Component],
|
|
61
|
+
stats: dict[str, ui.blocks.StatsCard],
|
|
62
|
+
grid: ui.blocks.DashboardGrid,
|
|
63
|
+
placeholders: list[str],
|
|
64
|
+
) -> None:
|
|
65
|
+
self.refs = refs # keyed schema widgets: refresh, cpu, top
|
|
66
|
+
self.stats = stats # the StatsCard blocks: users, orders, errors
|
|
67
|
+
self.grid = grid
|
|
68
|
+
self.placeholders = placeholders
|
|
69
|
+
self.tick = 0
|
|
70
|
+
|
|
71
|
+
def refresh(self) -> None:
|
|
72
|
+
"""Live update of the keyed widgets (as a timer or a push would do)."""
|
|
73
|
+
self.tick += 1
|
|
74
|
+
t = self.tick
|
|
75
|
+
refs = self.refs
|
|
76
|
+
self.stats["users"].set_stats(value=1200 + 7 * t, delta=round(0.5 * t, 1))
|
|
77
|
+
self.stats["orders"].set_stats(value=310 + t)
|
|
78
|
+
self.stats["errors"].set_stats(value=t % 3)
|
|
79
|
+
chart = refs["cpu"]
|
|
80
|
+
assert isinstance(chart, ui.LineChart)
|
|
81
|
+
chart.append({"t": t, "cpu": round(50 + 30 * math.sin(t / 3), 1)})
|
|
82
|
+
refs["top"].update(
|
|
83
|
+
data={"head": ["Service", "Latency ms"], "body": [["api", 40 + t], ["db", 12 + t % 5]]}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def build() -> Dashboard:
|
|
88
|
+
actions = ui.schema.Actions()
|
|
89
|
+
holder: list[Dashboard] = []
|
|
90
|
+
actions.add("dashboard.refresh", lambda: holder[0].refresh())
|
|
91
|
+
refs: dict[str, ui.Component] = {}
|
|
92
|
+
placeholders: list[str] = []
|
|
93
|
+
|
|
94
|
+
def widget(spec: dict[str, Any]) -> ui.Component:
|
|
95
|
+
tree = ui.schema.build(spec, actions=actions, unknown="placeholder")
|
|
96
|
+
refs.update(tree.refs)
|
|
97
|
+
placeholders.extend(tree.placeholders)
|
|
98
|
+
return tree.root
|
|
99
|
+
|
|
100
|
+
with ui.Stack():
|
|
101
|
+
widget(HEADER)
|
|
102
|
+
cards = {
|
|
103
|
+
key: ui.blocks.StatsCard(title=label, value=0, caption="live") for key, label in STATS
|
|
104
|
+
}
|
|
105
|
+
grid = ui.blocks.DashboardGrid(
|
|
106
|
+
[*cards.values(), widget(CHART), widget(UNKNOWN), widget(TABLE)],
|
|
107
|
+
spans=(4, 4, 4, 8, 4, 12),
|
|
108
|
+
)
|
|
109
|
+
holder.append(Dashboard(refs, cards, grid, placeholders))
|
|
110
|
+
return holder[0]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def main() -> None:
|
|
114
|
+
app = ui.Application(title="Dynamic dashboard", width=1100, height=800)
|
|
115
|
+
with app.page("/"):
|
|
116
|
+
build()
|
|
117
|
+
app.run()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
main()
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Server-driven form: a form generated from a validated schema.
|
|
2
|
+
|
|
3
|
+
The schema is plain data (as a server or a settings file would send it):
|
|
4
|
+
field types, required/min/max/pattern rules, options, a repeated list of
|
|
5
|
+
order lines, a nested group and a ``visible_when`` condition. Nothing in it is
|
|
6
|
+
executed: ``ui.Form.from_schema`` maps it to typed components and
|
|
7
|
+
``ui.validators`` rules, and the submit goes to a *registered* action. Python
|
|
8
|
+
validates again on submit (types, rules, the server check below) before the
|
|
9
|
+
action runs.
|
|
10
|
+
|
|
11
|
+
Run: ``uv run python examples/patterns/dynamic_form.py``
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from neutralino import ui
|
|
19
|
+
|
|
20
|
+
SCHEMA: dict[str, Any] = {
|
|
21
|
+
"fields": [
|
|
22
|
+
{"name": "name", "type": "text", "label": "Name", "required": True, "min_length": 2},
|
|
23
|
+
{"name": "email", "type": "email", "label": "E-mail", "required": True},
|
|
24
|
+
{
|
|
25
|
+
"name": "kind",
|
|
26
|
+
"type": "segmented",
|
|
27
|
+
"options": ["person", "company"],
|
|
28
|
+
"default": "person",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "company",
|
|
32
|
+
"type": "group",
|
|
33
|
+
"label": "Company",
|
|
34
|
+
"visible_when": {"field": "kind", "equals": "company"},
|
|
35
|
+
"fields": [
|
|
36
|
+
{"name": "title", "type": "text", "label": "Company name", "required": True},
|
|
37
|
+
{
|
|
38
|
+
"name": "vat",
|
|
39
|
+
"type": "text",
|
|
40
|
+
"label": "VAT number",
|
|
41
|
+
"required": True,
|
|
42
|
+
"pattern": "[A-Z]{2}[0-9]{6,10}",
|
|
43
|
+
"pattern_message": "Two letters and 6-10 digits",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "lines",
|
|
49
|
+
"type": "list",
|
|
50
|
+
"label": "Order lines",
|
|
51
|
+
"add_label": "Add line",
|
|
52
|
+
"min_items": 1,
|
|
53
|
+
"max_items": 5,
|
|
54
|
+
"default": [{"sku": "A-100", "qty": 1}],
|
|
55
|
+
"fields": [
|
|
56
|
+
{
|
|
57
|
+
"name": "sku",
|
|
58
|
+
"type": "select",
|
|
59
|
+
"label": "Item",
|
|
60
|
+
"options": ["A-100", "B-200", "C-300"],
|
|
61
|
+
"default": "A-100",
|
|
62
|
+
"required": True,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "qty",
|
|
66
|
+
"type": "integer",
|
|
67
|
+
"label": "Qty",
|
|
68
|
+
"min": 1,
|
|
69
|
+
"max": 99,
|
|
70
|
+
"default": 1,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{"name": "delivery", "type": "date", "label": "Delivery date", "placeholder": "YYYY-MM-DD"},
|
|
75
|
+
{"name": "newsletter", "type": "checkbox", "label": "Send me news"},
|
|
76
|
+
],
|
|
77
|
+
"submit_label": "Place order",
|
|
78
|
+
"reset_label": "Reset",
|
|
79
|
+
"submit_action": "place_order",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
BLOCKED_DOMAINS = {"example.invalid"}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def server_check(values: dict[str, Any]) -> dict[str, str] | None:
|
|
86
|
+
"""Authoritative server-side validation (after the field rules)."""
|
|
87
|
+
errors: dict[str, str] = {}
|
|
88
|
+
if str(values.get("email", "")).rsplit("@", 1)[-1] in BLOCKED_DOMAINS:
|
|
89
|
+
errors["email"] = "This e-mail domain is not accepted"
|
|
90
|
+
if sum(int(line["qty"]) for line in values.get("lines", [])) > 100:
|
|
91
|
+
errors["lines"] = "At most 100 items per order"
|
|
92
|
+
return errors or None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def build(orders: list[dict[str, Any]] | None = None) -> tuple[ui.Form, ui.schema.Actions]:
|
|
96
|
+
"""Build the form in the current container; submitted orders go to ``orders``."""
|
|
97
|
+
store = orders if orders is not None else []
|
|
98
|
+
actions = ui.schema.Actions()
|
|
99
|
+
|
|
100
|
+
@actions.action("place_order")
|
|
101
|
+
def place_order(ev: ui.schema.ActionEvent) -> None: # pyright: ignore[reportUnusedFunction]
|
|
102
|
+
store.append(ev.values)
|
|
103
|
+
window = ui.current_window()
|
|
104
|
+
if window is not None:
|
|
105
|
+
window.notify("Order placed", color="green")
|
|
106
|
+
|
|
107
|
+
form = ui.Form.from_schema(SCHEMA, actions=actions, validate=server_check)
|
|
108
|
+
return form, actions
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def main() -> None:
|
|
112
|
+
app = ui.Application(title="Dynamic form", width=720, height=820)
|
|
113
|
+
with app.page("/"), ui.Container(size="sm"):
|
|
114
|
+
ui.Title("New order", order=2)
|
|
115
|
+
build()
|
|
116
|
+
app.run()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
main()
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Server-driven table: columns and row actions from configuration.
|
|
2
|
+
|
|
3
|
+
The table's layout (columns, sort/filter options, row actions with
|
|
4
|
+
confirmation templates, page size) is plain data; the data comes from a
|
|
5
|
+
*registered* Python provider answered in bounded pages (paging, sort, search
|
|
6
|
+
and a role filter run in Python; only the visible page travels to the
|
|
7
|
+
window), and row actions go to a *registered* action. The confirm text
|
|
8
|
+
("Delete {name}?") is filled in the page with the row's values as plain text.
|
|
9
|
+
|
|
10
|
+
Run: ``uv run python examples/patterns/dynamic_table.py``
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from neutralino import ui
|
|
18
|
+
|
|
19
|
+
TOTAL = 5_000
|
|
20
|
+
ROLES = ["admin", "editor", "viewer"]
|
|
21
|
+
|
|
22
|
+
CONFIG: dict[str, Any] = {
|
|
23
|
+
"type": "DataTable",
|
|
24
|
+
"key": "people",
|
|
25
|
+
"provider": "people",
|
|
26
|
+
"props": {
|
|
27
|
+
"columns": [
|
|
28
|
+
{"key": "id", "title": "ID", "kind": "number", "sortable": True, "width": 80},
|
|
29
|
+
{"key": "name", "title": "Name", "sortable": True},
|
|
30
|
+
{"key": "role", "title": "Role", "kind": "badge", "filter": "select", "options": ROLES},
|
|
31
|
+
{"key": "active", "title": "Active", "kind": "boolean"},
|
|
32
|
+
],
|
|
33
|
+
"row_actions": [
|
|
34
|
+
{"action": "promote", "label": "Promote"},
|
|
35
|
+
{"action": "delete", "label": "Delete", "color": "red", "confirm": "Delete {name}?"},
|
|
36
|
+
],
|
|
37
|
+
"page_size": 20,
|
|
38
|
+
"searchable": True,
|
|
39
|
+
"selection": "multiple",
|
|
40
|
+
},
|
|
41
|
+
"on": {"row_action": "people.row_action"},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class People:
|
|
46
|
+
"""A synthetic directory: rows are computed per requested window."""
|
|
47
|
+
|
|
48
|
+
def __init__(self, total: int = TOTAL) -> None:
|
|
49
|
+
self.total = total
|
|
50
|
+
self.deleted: set[int] = set()
|
|
51
|
+
self.promoted: set[int] = set()
|
|
52
|
+
self.queries: list[ui.TableQuery] = []
|
|
53
|
+
|
|
54
|
+
def row(self, i: int) -> dict[str, Any]:
|
|
55
|
+
role = "admin" if i in self.promoted else ROLES[i % 3]
|
|
56
|
+
return {"id": i, "name": f"Person {i}", "role": role, "active": i % 4 != 0}
|
|
57
|
+
|
|
58
|
+
def provider(self, q: ui.TableQuery) -> ui.TablePage:
|
|
59
|
+
self.queries.append(q)
|
|
60
|
+
ids: list[int] | range = range(1, self.total + 1)
|
|
61
|
+
if self.deleted:
|
|
62
|
+
ids = [i for i in ids if i not in self.deleted]
|
|
63
|
+
role = q.filters.get("role")
|
|
64
|
+
if role:
|
|
65
|
+
ids = [i for i in ids if self.row(i)["role"] == role]
|
|
66
|
+
if q.search:
|
|
67
|
+
needle = q.search.lower()
|
|
68
|
+
ids = [i for i in ids if needle in f"person {i}"]
|
|
69
|
+
if q.sort in ("id", "name") and q.direction == "desc":
|
|
70
|
+
ids = list(reversed(ids))
|
|
71
|
+
window = ids[q.offset : q.offset + q.limit]
|
|
72
|
+
return ui.TablePage(rows=[self.row(i) for i in window], total=len(ids))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def build(people: People | None = None) -> tuple[ui.DataTable, People, list[tuple[str, Any]]]:
|
|
76
|
+
data = people or People()
|
|
77
|
+
log: list[tuple[str, Any]] = []
|
|
78
|
+
tables: list[ui.DataTable] = []
|
|
79
|
+
actions = ui.schema.Actions()
|
|
80
|
+
actions.add_provider("people", data.provider)
|
|
81
|
+
|
|
82
|
+
def on_row_action(ev: ui.schema.ActionEvent) -> None:
|
|
83
|
+
assert isinstance(ev.event, ui.RowActionEvent)
|
|
84
|
+
action, key = ev.event.action, int(ev.event.key)
|
|
85
|
+
log.append((action, key))
|
|
86
|
+
if action == "delete":
|
|
87
|
+
data.deleted.add(key)
|
|
88
|
+
elif action == "promote":
|
|
89
|
+
data.promoted.add(key)
|
|
90
|
+
tables[0].refresh() # the page re-queries the visible page
|
|
91
|
+
|
|
92
|
+
actions.add("people.row_action", on_row_action)
|
|
93
|
+
tree = ui.schema.build(CONFIG, actions=actions)
|
|
94
|
+
table = tree.refs["people"]
|
|
95
|
+
assert isinstance(table, ui.DataTable)
|
|
96
|
+
tables.append(table)
|
|
97
|
+
return table, data, log
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def main() -> None:
|
|
101
|
+
app = ui.Application(title="Dynamic table", width=1000, height=800)
|
|
102
|
+
with app.page("/"), ui.Stack():
|
|
103
|
+
ui.Title("People", order=2)
|
|
104
|
+
build()
|
|
105
|
+
app.run()
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
main()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Page side of the error_reporting example: forwards uncaught page errors to Python and
|
|
2
|
+
// registers two buttons that cause them (a real user would meet them by accident).
|
|
3
|
+
const backend = window.NeutralinoUI.session.backend;
|
|
4
|
+
const report = (kind, message) =>
|
|
5
|
+
backend.invoke('report_page_error', { kind, message: String(message).slice(0, 300) }).catch(() => {});
|
|
6
|
+
window.addEventListener('error', (e) => report('error', e.message));
|
|
7
|
+
window.addEventListener('unhandledrejection', (e) => report('rejection', e.reason?.message ?? e.reason));
|
|
8
|
+
|
|
9
|
+
window.NeutralinoUI.registerComponent('error-trigger', () => ({
|
|
10
|
+
mount(el) {
|
|
11
|
+
for (const [label, run] of [
|
|
12
|
+
['Throw in page', () => setTimeout(() => { throw new Error('page failure token=abc123'); }, 0)],
|
|
13
|
+
['Reject in page', () => Promise.reject(new Error('page rejection'))],
|
|
14
|
+
]) {
|
|
15
|
+
const b = document.createElement('button');
|
|
16
|
+
b.textContent = label;
|
|
17
|
+
b.setAttribute('data-error-trigger', label);
|
|
18
|
+
b.onclick = run;
|
|
19
|
+
el.append(b);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
update() {},
|
|
23
|
+
dispose() {},
|
|
24
|
+
}));
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""Error reporting: Python and page errors in one list, a local report with redaction.
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/patterns/error_reporting.py
|
|
4
|
+
|
|
5
|
+
Two sources feed one bounded list: failures of Python callbacks arrive through
|
|
6
|
+
``app.on_error`` and uncaught errors of the page through the exposed function
|
|
7
|
+
``report_page_error`` (``error_reporting.mjs`` registers the window listeners).
|
|
8
|
+
Every message is redacted first (home directory, e-mail addresses, ``key=value``
|
|
9
|
+
secrets, bearer tokens). "Send report" does not send anything anywhere: it writes
|
|
10
|
+
one JSON bundle (environment, application, the errors) into the application's
|
|
11
|
+
state directory through ``filesystem.writeFile`` and shows where, so the user can
|
|
12
|
+
attach it to a bug report. The example makes no network request.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import platform
|
|
19
|
+
import re
|
|
20
|
+
import sys
|
|
21
|
+
import time
|
|
22
|
+
from collections import deque
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
from neutralino import ui
|
|
27
|
+
|
|
28
|
+
ROUTES = ["filesystem.writeFile"]
|
|
29
|
+
PAGE_MODULE = "error_reporting.mjs" # next to this file; added in main()
|
|
30
|
+
MAX_ERRORS = 50
|
|
31
|
+
SECRET = re.compile(
|
|
32
|
+
r"(?i)\b(password|passwd|token|secret|api[_-]?key|authorization)\b(\s*[=:]\s*)(?:bearer\s+)?\S+"
|
|
33
|
+
)
|
|
34
|
+
BEARER = re.compile(r"(?i)\bbearer\s+[\w.~+/=-]+")
|
|
35
|
+
EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.-]+")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def redact(text: str, home: str | None = None) -> str:
|
|
39
|
+
"""Remove what must not leave the machine from an error message."""
|
|
40
|
+
home = home if home is not None else str(Path.home())
|
|
41
|
+
if home and home != "/":
|
|
42
|
+
text = text.replace(home, "~")
|
|
43
|
+
text = SECRET.sub(lambda m: f"{m.group(1)}{m.group(2)}<redacted>", text)
|
|
44
|
+
text = BEARER.sub("Bearer <redacted>", text) # a bearer token on its own
|
|
45
|
+
return EMAIL.sub("<email>", text)[:300]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Reporter:
|
|
49
|
+
def __init__(self, app: ui.AsyncApplication) -> None:
|
|
50
|
+
self.app = app
|
|
51
|
+
self.errors: deque[dict[str, Any]] = deque(maxlen=MAX_ERRORS)
|
|
52
|
+
self.view: ui.State[list[str]] = ui.State([])
|
|
53
|
+
|
|
54
|
+
def add(self, source: str, message: str) -> None:
|
|
55
|
+
entry = {"source": source, "message": redact(message), "at": time.strftime("%H:%M:%S")}
|
|
56
|
+
self.errors.append(entry)
|
|
57
|
+
self.view.set([f"[{e['source']}] {e['message']}" for e in self.errors])
|
|
58
|
+
|
|
59
|
+
def bundle(self) -> dict[str, Any]:
|
|
60
|
+
return {
|
|
61
|
+
"created": time.strftime("%Y-%m-%dT%H:%M:%S%z"),
|
|
62
|
+
"application": {"id": self.app.app_id},
|
|
63
|
+
"environment": {
|
|
64
|
+
"python": platform.python_version(),
|
|
65
|
+
"system": platform.system(),
|
|
66
|
+
"machine": platform.machine(),
|
|
67
|
+
"frozen": bool(getattr(sys, "frozen", False)),
|
|
68
|
+
},
|
|
69
|
+
"errors": list(self.errors),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async def send(self) -> Path:
|
|
73
|
+
"""Write the report; nothing is sent over any network."""
|
|
74
|
+
directory = self.app.paths.ensure("state") / "reports"
|
|
75
|
+
directory.mkdir(exist_ok=True)
|
|
76
|
+
path = directory / f"report-{time.strftime('%Y%m%d-%H%M%S')}-{len(self.errors)}.json"
|
|
77
|
+
await self.app.native.filesystem.write_file(path, json.dumps(self.bundle(), indent=2))
|
|
78
|
+
return path
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def build(app: ui.AsyncApplication) -> dict[str, Any]:
|
|
82
|
+
rep = Reporter(app)
|
|
83
|
+
|
|
84
|
+
@app.expose()
|
|
85
|
+
def report_page_error(kind: str, message: str) -> None:
|
|
86
|
+
"""Called by ``error_reporting.mjs`` for uncaught errors and promise rejections."""
|
|
87
|
+
rep.add("page", f"{str(kind)[:20]}: {str(message)[:300]}")
|
|
88
|
+
|
|
89
|
+
app.on_error(lambda window, err: rep.add("python", f"{type(err).__name__}: {err}"))
|
|
90
|
+
|
|
91
|
+
def explode(ev: ui.Event) -> None:
|
|
92
|
+
raise RuntimeError("handler failed for ada@example.com with password=hunter2")
|
|
93
|
+
|
|
94
|
+
async def send(ev: ui.Event) -> None:
|
|
95
|
+
status.update(text=f"report written to {await rep.send()}")
|
|
96
|
+
|
|
97
|
+
with app.page("/"), ui.Stack(gap="sm"):
|
|
98
|
+
ui.Title("Error reporting", order=3)
|
|
99
|
+
with ui.Group():
|
|
100
|
+
fail = ui.Button("Fail in Python", on_click=explode, color="red", variant="light")
|
|
101
|
+
trigger = ui.CustomComponent("error-trigger")
|
|
102
|
+
listing = ui.Code("", block=True)
|
|
103
|
+
send_button = ui.Button("Send report", on_click=send)
|
|
104
|
+
status = ui.Text("no report written", size="xs", dimmed=True)
|
|
105
|
+
rep.view.bind(listing, "text", lambda lines: "\n".join(lines) or "no errors")
|
|
106
|
+
return {
|
|
107
|
+
"reporter": rep, "fail": fail, "trigger": trigger, "listing": listing,
|
|
108
|
+
"send": send_button, "status": status,
|
|
109
|
+
} # fmt: skip
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
async def main() -> None:
|
|
113
|
+
app = ui.AsyncApplication(
|
|
114
|
+
title="Error reporting", width=520, height=360, profile="custom", native_allow_list=ROUTES
|
|
115
|
+
)
|
|
116
|
+
build(app)
|
|
117
|
+
app.add_js_module(PAGE_MODULE) # relative paths start at this file's directory
|
|
118
|
+
await app.run()
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
import asyncio
|
|
123
|
+
|
|
124
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"""Errors and timeouts: typed codes, sanitised messages, one place to map them.
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/patterns/errors_timeouts.py
|
|
4
|
+
|
|
5
|
+
What crosses the boundary is an ``RpcError`` with a ``code``. Raise your own
|
|
6
|
+
(``RpcError("NOT_FOUND", message, details)``) for expected failures: code,
|
|
7
|
+
message and JSON details reach the page unchanged. Any other exception is an
|
|
8
|
+
internal failure: the page sees ``INTERNAL_ERROR`` / "internal error", never
|
|
9
|
+
the text or traceback (those stay in the Python log). A call that exceeds its
|
|
10
|
+
``timeout`` (per method or the page's ``timeoutMs``) fails with ``TIMEOUT``; a
|
|
11
|
+
page that went away gives ``DISCONNECTED``.
|
|
12
|
+
|
|
13
|
+
``user_message`` is the single mapping from codes to what the user reads, used
|
|
14
|
+
by the page-side ``catch`` and by ``app.on_error`` for failures inside UI
|
|
15
|
+
callbacks. ``retry`` shows the retry rule: only ``TIMEOUT`` and
|
|
16
|
+
``DISCONNECTED`` are worth another attempt.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import asyncio
|
|
22
|
+
from collections.abc import Awaitable, Callable
|
|
23
|
+
from typing import Any, TypeVar
|
|
24
|
+
|
|
25
|
+
from neutralino import NativeError, RpcError, ui
|
|
26
|
+
|
|
27
|
+
T = TypeVar("T")
|
|
28
|
+
|
|
29
|
+
MESSAGES = {
|
|
30
|
+
"NOT_FOUND": "That item does not exist.",
|
|
31
|
+
"INVALID_PARAMS": "Please check the values you entered.",
|
|
32
|
+
"TIMEOUT": "This is taking too long. Try again.",
|
|
33
|
+
"DISCONNECTED": "The window lost its connection. Reload it.",
|
|
34
|
+
"CANCELLED": "Cancelled.",
|
|
35
|
+
"INTERNAL_ERROR": "Something went wrong. It has been logged.",
|
|
36
|
+
}
|
|
37
|
+
RETRYABLE = {"TIMEOUT", "DISCONNECTED"}
|
|
38
|
+
ITEMS = {"a": "Alpha", "b": "Beta"}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def user_message(err: BaseException) -> str:
|
|
42
|
+
"""The text for ``err``; unknown exceptions never leak their own message."""
|
|
43
|
+
if isinstance(err, RpcError):
|
|
44
|
+
return MESSAGES.get(err.code, MESSAGES["INTERNAL_ERROR"])
|
|
45
|
+
if isinstance(err, NativeError): # the runtime's own error (file missing, ...)
|
|
46
|
+
return f"The system refused: {err.code}."
|
|
47
|
+
if isinstance(err, TimeoutError):
|
|
48
|
+
return MESSAGES["TIMEOUT"]
|
|
49
|
+
return MESSAGES["INTERNAL_ERROR"]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
async def retry(call: Callable[[], Awaitable[T]], attempts: int = 3, pause: float = 0.05) -> T:
|
|
53
|
+
"""Await ``call()``; retry only transient RpcErrors, at most ``attempts`` times."""
|
|
54
|
+
for n in range(1, attempts + 1):
|
|
55
|
+
try:
|
|
56
|
+
return await call()
|
|
57
|
+
except RpcError as err:
|
|
58
|
+
if err.code not in RETRYABLE or n == attempts:
|
|
59
|
+
raise
|
|
60
|
+
await asyncio.sleep(pause * n)
|
|
61
|
+
raise AssertionError("unreachable")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def build(app: ui.Application | ui.AsyncApplication) -> list[str]:
|
|
65
|
+
shown: list[str] = [] # what on_error told the user, newest last
|
|
66
|
+
|
|
67
|
+
@app.expose()
|
|
68
|
+
def lookup(key: str) -> str:
|
|
69
|
+
if key not in ITEMS:
|
|
70
|
+
raise RpcError("NOT_FOUND", f"no item {key!r}", {"key": key})
|
|
71
|
+
return ITEMS[key]
|
|
72
|
+
|
|
73
|
+
@app.expose()
|
|
74
|
+
def explode() -> None:
|
|
75
|
+
raise RuntimeError("secret detail: /home/user/.config/token") # never reaches the page
|
|
76
|
+
|
|
77
|
+
@app.expose(timeout=0.3)
|
|
78
|
+
async def slow(seconds: float) -> str:
|
|
79
|
+
await asyncio.sleep(seconds)
|
|
80
|
+
return "finished"
|
|
81
|
+
|
|
82
|
+
@app.on_error
|
|
83
|
+
def report(window: Any, err: BaseException) -> None:
|
|
84
|
+
msg = user_message(err)
|
|
85
|
+
shown.append(msg)
|
|
86
|
+
if window is not None: # the window whose callback failed
|
|
87
|
+
ui.Window(window).notify(msg, title="Error", color="red")
|
|
88
|
+
|
|
89
|
+
def not_found(ev: ui.Event) -> None:
|
|
90
|
+
raise RpcError("NOT_FOUND", "no such record")
|
|
91
|
+
|
|
92
|
+
def crash(ev: ui.Event) -> None:
|
|
93
|
+
raise RuntimeError("secret detail: /home/user/.config/token")
|
|
94
|
+
|
|
95
|
+
with app.page("/"), ui.Group():
|
|
96
|
+
ui.Button("Missing record", on_click=not_found)
|
|
97
|
+
ui.Button("Crash", on_click=crash, color="red")
|
|
98
|
+
return shown
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def main() -> None:
|
|
102
|
+
app = ui.Application(title="Errors and timeouts", width=480, height=240)
|
|
103
|
+
build(app)
|
|
104
|
+
app.run()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
if __name__ == "__main__":
|
|
108
|
+
main()
|