neutralino-python 0.1.0rc1__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-C2NUKJAE.js +1 -0
- neutralino/_data/renderer/assets/carousel-D1j1SkWR.css +1 -0
- neutralino/_data/renderer/assets/carousel-DHnOKa8c.js +1 -0
- neutralino/_data/renderer/assets/chunk-CCkLOSkX.css +1 -0
- neutralino/_data/renderer/assets/chunk-CLVygP7p.js +9 -0
- neutralino/_data/renderer/assets/codehighlight-CXJaU0yv.js +10 -0
- neutralino/_data/renderer/assets/codehighlight-THJMNDh8.css +1 -0
- neutralino/_data/renderer/assets/codemirror-DX0MbxKq.js +2 -0
- neutralino/_data/renderer/assets/css-BotC7byr.js +1 -0
- neutralino/_data/renderer/assets/dist-3kB5bJpS.js +23 -0
- neutralino/_data/renderer/assets/dist-6zrr4MrK.js +1 -0
- neutralino/_data/renderer/assets/dist-Beotrn8G.js +1 -0
- neutralino/_data/renderer/assets/dist-CCJHv8n0.js +11 -0
- neutralino/_data/renderer/assets/dist-CdYA9or5.js +1 -0
- neutralino/_data/renderer/assets/dist-D2p_6o_g.js +1 -0
- neutralino/_data/renderer/assets/dnd-DkNumIKC.js +5 -0
- neutralino/_data/renderer/assets/dropzone-aPCBPjDN.css +1 -0
- neutralino/_data/renderer/assets/dropzone-agrigkXv.js +1 -0
- neutralino/_data/renderer/assets/embla-carousel-react.esm-_ztrE73N.js +1 -0
- neutralino/_data/renderer/assets/emoji-Cj3VQHg8.js +1 -0
- neutralino/_data/renderer/assets/emoji-DV8OzU1E.css +1 -0
- neutralino/_data/renderer/assets/esm-DbOmMyz5.js +82 -0
- neutralino/_data/renderer/assets/highlight-Dlb5DJwL.css +1 -0
- neutralino/_data/renderer/assets/highlight-LH6Cyuz6.js +3 -0
- neutralino/_data/renderer/assets/html-CpATC083.js +1 -0
- neutralino/_data/renderer/assets/icon-chunk-C-4QDF6w.js +1 -0
- neutralino/_data/renderer/assets/index-CqHW60Dy.js +69 -0
- neutralino/_data/renderer/assets/index-TWpF4Lef.css +1 -0
- neutralino/_data/renderer/assets/javascript-D2QSKlDI.js +1 -0
- neutralino/_data/renderer/assets/json-D8zfYii3.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BijRfmPy.js +1 -0
- neutralino/_data/renderer/assets/lightbox-BzKDpkAD.css +1 -0
- neutralino/_data/renderer/assets/markdown-Cpthnhzg.js +77 -0
- neutralino/_data/renderer/assets/markdown-CsS2tf5C.js +5 -0
- neutralino/_data/renderer/assets/python-B477ud9A.js +9 -0
- neutralino/_data/renderer/assets/richtext-BwtgvH7-.js +137 -0
- neutralino/_data/renderer/assets/richtext-DIAsHMuK.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Ccstaz1-.css +1 -0
- neutralino/_data/renderer/assets/spotlight-Db1pwUWd.js +1 -0
- neutralino/_data/renderer/assets/sql-DbpHRl6F.js +2 -0
- neutralino/_data/renderer/assets/with-selector-CUfuSYau.js +1 -0
- neutralino/_data/renderer/assets/yaml-BPsr1O3S.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 +1261 -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.0rc1.dist-info/METADATA +117 -0
- neutralino_python-0.1.0rc1.dist-info/RECORD +521 -0
- neutralino_python-0.1.0rc1.dist-info/WHEEL +4 -0
- neutralino_python-0.1.0rc1.dist-info/entry_points.txt +3 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/LICENSE +21 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/THIRD_PARTY_NOTICES.md +16 -0
- neutralino_python-0.1.0rc1.dist-info/licenses/src/neutralino/_data/renderer/LICENSES/packages.json +1838 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Run a fixed command through the runtime (``os.execCommand``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/exec_command.py
|
|
4
|
+
|
|
5
|
+
Pick one of a few fixed commands (``COMMANDS``: there is no free-form input) and
|
|
6
|
+
press "Run": after a confirmation that shows the exact command line, the runtime
|
|
7
|
+
executes it and the page shows standard output, standard error, the exit code
|
|
8
|
+
and the duration. "Slow" sleeps for three seconds under a one second SDK
|
|
9
|
+
timeout, which ends the wait with a timeout (the command itself keeps running
|
|
10
|
+
until it finishes). The runtime starts commands with ``/bin/sh -c``; never put
|
|
11
|
+
untrusted text in one.
|
|
12
|
+
|
|
13
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import asyncio
|
|
19
|
+
import time
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
from neutralino import CallTimeoutError, NativeError, ui
|
|
23
|
+
|
|
24
|
+
ROUTES = ["os.execCommand"]
|
|
25
|
+
COMMANDS: dict[str, tuple[str, float | None]] = {
|
|
26
|
+
"Echo": ("echo hello from exec", None),
|
|
27
|
+
"System name": ("uname -s", None),
|
|
28
|
+
"Missing file": ("ls /nonexistent-neutralino-example", None),
|
|
29
|
+
"Slow": ("sleep 3", 1.0),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def build(
|
|
34
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
35
|
+
) -> dict[str, ui.Component]:
|
|
36
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
37
|
+
ui.Title("Run a command", order=3)
|
|
38
|
+
pick = ui.Select(label="Command", data=list(COMMANDS), value="Echo")
|
|
39
|
+
status = ui.Text("ready")
|
|
40
|
+
out = ui.Code("", block=True)
|
|
41
|
+
|
|
42
|
+
async def run(ev: ui.Event) -> None:
|
|
43
|
+
label = pick.value if isinstance(pick.value, str) and pick.value in COMMANDS else "Echo"
|
|
44
|
+
command, timeout = COMMANDS[label]
|
|
45
|
+
if not await app.main_window.confirm(
|
|
46
|
+
"Run command", f"Run this command?\n{command}", confirm_label="Run"
|
|
47
|
+
):
|
|
48
|
+
status.update(text="cancelled")
|
|
49
|
+
return
|
|
50
|
+
started = time.monotonic()
|
|
51
|
+
try:
|
|
52
|
+
result = await app.native.os.exec_command(command, timeout=timeout)
|
|
53
|
+
except CallTimeoutError:
|
|
54
|
+
status.update(text=f"timed out after {time.monotonic() - started:.1f} s")
|
|
55
|
+
return
|
|
56
|
+
except NativeError as err:
|
|
57
|
+
status.update(text=f"failed: {err.code}")
|
|
58
|
+
return
|
|
59
|
+
out.update(
|
|
60
|
+
text=f"stdout: {result['stdOut'].strip()}\nstderr: {result['stdErr'].strip()}"
|
|
61
|
+
)
|
|
62
|
+
status.update(
|
|
63
|
+
text=f"exit code {result['exitCode']} in {time.monotonic() - started:.2f} s"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
run_b = ui.Button("Run", on_click=run)
|
|
67
|
+
return {"pick": pick, "status": status, "out": out, "run": run_b}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def main() -> None:
|
|
71
|
+
app = ui.AsyncApplication(
|
|
72
|
+
title="Run a command", width=520, height=420, profile="custom", native_allow_list=ROUTES
|
|
73
|
+
)
|
|
74
|
+
build(app)
|
|
75
|
+
asyncio.run(app.run())
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Pick a folder with the native dialog and list it (``os.showFolderDialog``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/folder.py
|
|
4
|
+
|
|
5
|
+
"Choose folder" shows the system folder dialog, starting in a sandbox directory
|
|
6
|
+
the example creates with a few sample entries, then lists the chosen folder in
|
|
7
|
+
a table with ``filesystem.readDirectory`` (read only, one level). Cancelling the
|
|
8
|
+
dialog changes nothing. The dialog waits for the user (up to a day), not for the
|
|
9
|
+
SDK's usual 30 second call timeout.
|
|
10
|
+
|
|
11
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import tempfile
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
from neutralino import NativeError, ui
|
|
21
|
+
|
|
22
|
+
ROUTES = ["os.showFolderDialog", "filesystem.readDirectory"]
|
|
23
|
+
DIALOG_TIMEOUT = 24 * 3600.0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def build(
|
|
27
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
28
|
+
) -> dict[str, ui.Component]:
|
|
29
|
+
root = root or Path(tempfile.mkdtemp(prefix="neutralino-folder-"))
|
|
30
|
+
root.mkdir(parents=True, exist_ok=True)
|
|
31
|
+
(root / "sub").mkdir(exist_ok=True)
|
|
32
|
+
(root / "a.txt").write_text("alpha\n")
|
|
33
|
+
(root / "b.txt").write_text("bravo\n")
|
|
34
|
+
|
|
35
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
36
|
+
ui.Title("Choose a folder", order=3)
|
|
37
|
+
ui.Text(f"The dialog starts in: {root}", size="xs", dimmed=True)
|
|
38
|
+
status = ui.Text("ready")
|
|
39
|
+
table = ui.Table(data={"head": ["Name", "Type"], "body": []})
|
|
40
|
+
|
|
41
|
+
async def choose(ev: ui.Event) -> None:
|
|
42
|
+
try:
|
|
43
|
+
picked = await app.native.os.show_folder_dialog(
|
|
44
|
+
"Choose a folder", default_path=root, timeout=DIALOG_TIMEOUT
|
|
45
|
+
)
|
|
46
|
+
if not picked:
|
|
47
|
+
status.update(text="cancelled")
|
|
48
|
+
return
|
|
49
|
+
entries = await app.native.filesystem.read_directory(picked)
|
|
50
|
+
except NativeError as err:
|
|
51
|
+
status.update(text=f"failed: {err.code}")
|
|
52
|
+
return
|
|
53
|
+
rows = sorted((e["entry"], e["type"].lower()) for e in entries)
|
|
54
|
+
table.update(data={"head": ["Name", "Type"], "body": [list(r) for r in rows]})
|
|
55
|
+
status.update(text=f"{picked}: {len(rows)} entries")
|
|
56
|
+
|
|
57
|
+
choose_b = ui.Button("Choose folder", on_click=choose)
|
|
58
|
+
return {"status": status, "table": table, "choose": choose_b}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main() -> None:
|
|
62
|
+
app = ui.AsyncApplication(
|
|
63
|
+
title="Choose a folder", width=520, height=420, profile="custom", native_allow_list=ROUTES
|
|
64
|
+
)
|
|
65
|
+
build(app)
|
|
66
|
+
asyncio.run(app.run())
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
main()
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""The window icon and a badge count (``window.setIcon``, ``window.setBadge``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/icon_badge.py
|
|
4
|
+
|
|
5
|
+
"Set icon" generates a small PNG in Python (a coloured square with a letter
|
|
6
|
+
bar, chosen with the colour menu), copies it into the runtime's private
|
|
7
|
+
instance directory and sets it as the window icon (``Window.set_icon``, which
|
|
8
|
+
ends in ``window.setIcon``). "Set badge" sets a count on the application icon
|
|
9
|
+
(``window.setBadge``; 0 clears it). Support differs by platform: the badge is
|
|
10
|
+
a dock or taskbar feature of macOS and Windows and of some Linux desktops;
|
|
11
|
+
where it is unsupported the runtime accepts the call and nothing shows. A
|
|
12
|
+
window manager reads the icon; a bare X server shows none.
|
|
13
|
+
|
|
14
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import asyncio
|
|
20
|
+
import struct
|
|
21
|
+
import tempfile
|
|
22
|
+
import zlib
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
from neutralino import NativeError, ValidationError, ui
|
|
27
|
+
|
|
28
|
+
ROUTES = ["window.setIcon", "window.setBadge"]
|
|
29
|
+
COLORS = {"Blue": (59, 130, 246), "Green": (34, 197, 94), "Red": (239, 68, 68)}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def icon_png(path: Path, rgb: tuple[int, int, int], size: int = 64) -> Path:
|
|
33
|
+
"""A ``size`` x ``size`` PNG: a square of ``rgb`` with a white bar (8-bit RGBA)."""
|
|
34
|
+
|
|
35
|
+
def chunk(kind: bytes, data: bytes) -> bytes:
|
|
36
|
+
body = kind + data
|
|
37
|
+
return struct.pack(">I", len(data)) + body + struct.pack(">I", zlib.crc32(body))
|
|
38
|
+
|
|
39
|
+
rows = bytearray()
|
|
40
|
+
for y in range(size):
|
|
41
|
+
rows += b"\x00"
|
|
42
|
+
for _x in range(size):
|
|
43
|
+
bar = size // 2 - size // 8 <= y < size // 2 + size // 8
|
|
44
|
+
rows += bytes((255, 255, 255, 255) if bar else (*rgb, 255))
|
|
45
|
+
path.write_bytes(
|
|
46
|
+
b"\x89PNG\r\n\x1a\n"
|
|
47
|
+
+ chunk(b"IHDR", struct.pack(">IIBBBBB", size, size, 8, 6, 0, 0, 0))
|
|
48
|
+
+ chunk(b"IDAT", zlib.compress(bytes(rows)))
|
|
49
|
+
+ chunk(b"IEND", b"")
|
|
50
|
+
)
|
|
51
|
+
return path
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def build(
|
|
55
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
56
|
+
) -> dict[str, ui.Component]:
|
|
57
|
+
root = root or Path(tempfile.mkdtemp(prefix="neutralino-icon-badge-"))
|
|
58
|
+
root.mkdir(parents=True, exist_ok=True)
|
|
59
|
+
|
|
60
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
61
|
+
ui.Title("Icon and badge", order=3)
|
|
62
|
+
color = ui.Select(label="Icon colour", data=list(COLORS), value="Blue")
|
|
63
|
+
count = ui.NumberInput(label="Badge count", value=3, min=0, max=999)
|
|
64
|
+
status = ui.Text("ready")
|
|
65
|
+
|
|
66
|
+
async def set_icon(ev: ui.Event) -> None:
|
|
67
|
+
name = color.value if isinstance(color.value, str) and color.value in COLORS else "Blue"
|
|
68
|
+
png = icon_png(root / f"icon-{name.lower()}.png", COLORS[name])
|
|
69
|
+
try:
|
|
70
|
+
await app.main_window.set_icon(png)
|
|
71
|
+
except (NativeError, ValidationError) as err:
|
|
72
|
+
status.update(text=f"icon failed: {getattr(err, 'code', 'INVALID')}")
|
|
73
|
+
return
|
|
74
|
+
status.update(text=f"icon set ({name.lower()})")
|
|
75
|
+
|
|
76
|
+
async def set_badge(ev: ui.Event) -> None:
|
|
77
|
+
value: Any = count.value
|
|
78
|
+
n = int(value) if isinstance(value, (int, float)) and not isinstance(value, bool) else 0
|
|
79
|
+
try:
|
|
80
|
+
await app.native.window.set_badge(max(0, min(999, n)))
|
|
81
|
+
except NativeError as err:
|
|
82
|
+
status.update(text=f"badge failed: {err.code}")
|
|
83
|
+
return
|
|
84
|
+
status.update(text=f"badge set to {max(0, min(999, n))}")
|
|
85
|
+
|
|
86
|
+
with ui.Group(gap="xs"):
|
|
87
|
+
icon_b = ui.Button("Set icon", on_click=set_icon)
|
|
88
|
+
badge_b = ui.Button("Set badge", on_click=set_badge, variant="light")
|
|
89
|
+
return {"color": color, "count": count, "status": status, "icon": icon_b, "badge": badge_b}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def main() -> None:
|
|
93
|
+
app = ui.AsyncApplication(
|
|
94
|
+
title="Icon and badge", width=420, height=320, profile="custom", native_allow_list=ROUTES
|
|
95
|
+
)
|
|
96
|
+
build(app)
|
|
97
|
+
asyncio.run(app.run())
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
main()
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Clipboard image (``clipboard.writeImage`` and ``clipboard.readImage``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/image.py
|
|
4
|
+
|
|
5
|
+
"Write gradient" generates a small RGBA gradient in Python and puts it on the
|
|
6
|
+
system clipboard (``clipboard.writeImage``); "Read image" reads whatever image
|
|
7
|
+
the clipboard holds (``clipboard.readImage``, converted to RGBA), encodes it as
|
|
8
|
+
a PNG with the standard library and shows it in the page as a data URI. The
|
|
9
|
+
clipboard is shared with every other program, so writing is off until "Allow
|
|
10
|
+
overwriting my clipboard" is switched on, and reading an image copied from
|
|
11
|
+
another program works as well.
|
|
12
|
+
|
|
13
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import asyncio
|
|
19
|
+
import base64
|
|
20
|
+
import struct
|
|
21
|
+
import zlib
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
from neutralino import NativeError, ui
|
|
25
|
+
from neutralino.api.types import ClipboardImageInput
|
|
26
|
+
|
|
27
|
+
ROUTES = ["clipboard.writeImage", "clipboard.readImage"]
|
|
28
|
+
SIZE = 16
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def gradient_bgra(size: int = SIZE) -> bytes:
|
|
32
|
+
"""``size`` x ``size`` pixels, red grows to the right, green downwards, blue fixed."""
|
|
33
|
+
out = bytearray()
|
|
34
|
+
for y in range(size):
|
|
35
|
+
for x in range(size):
|
|
36
|
+
out += bytes((128, y * 255 // (size - 1), x * 255 // (size - 1), 255)) # B G R A
|
|
37
|
+
return bytes(out)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def png_rgba(width: int, height: int, rgba: bytes) -> bytes:
|
|
41
|
+
"""A PNG (8-bit RGBA) built with ``zlib`` and ``struct``."""
|
|
42
|
+
|
|
43
|
+
def chunk(kind: bytes, data: bytes) -> bytes:
|
|
44
|
+
body = kind + data
|
|
45
|
+
return struct.pack(">I", len(data)) + body + struct.pack(">I", zlib.crc32(body))
|
|
46
|
+
|
|
47
|
+
rows = b"".join(b"\x00" + rgba[y * width * 4 : (y + 1) * width * 4] for y in range(height))
|
|
48
|
+
return (
|
|
49
|
+
b"\x89PNG\r\n\x1a\n"
|
|
50
|
+
+ chunk(b"IHDR", struct.pack(">IIBBBBB", width, height, 8, 6, 0, 0, 0))
|
|
51
|
+
+ chunk(b"IDAT", zlib.compress(rows))
|
|
52
|
+
+ chunk(b"IEND", b"")
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def build(
|
|
57
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
58
|
+
) -> dict[str, ui.Component]:
|
|
59
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
60
|
+
ui.Title("Clipboard image", order=3)
|
|
61
|
+
allow = ui.Switch(label="Allow overwriting my clipboard", checked=False)
|
|
62
|
+
status = ui.Text("ready")
|
|
63
|
+
preview = ui.Image(alt="clipboard image", w=96, h=96)
|
|
64
|
+
|
|
65
|
+
async def write(ev: ui.Event) -> None:
|
|
66
|
+
if allow.checked is not True:
|
|
67
|
+
status.update(text="writing is off: switch on 'Allow overwriting my clipboard'")
|
|
68
|
+
return
|
|
69
|
+
image: ClipboardImageInput = {
|
|
70
|
+
"width": SIZE,
|
|
71
|
+
"height": SIZE,
|
|
72
|
+
"bpp": 32,
|
|
73
|
+
"bpr": SIZE * 4,
|
|
74
|
+
"redMask": 0xFF0000,
|
|
75
|
+
"greenMask": 0xFF00,
|
|
76
|
+
"blueMask": 0xFF,
|
|
77
|
+
"alphaMask": 0xFF000000,
|
|
78
|
+
"redShift": 16,
|
|
79
|
+
"greenShift": 8,
|
|
80
|
+
"blueShift": 0,
|
|
81
|
+
"alphaShift": 24,
|
|
82
|
+
"data": gradient_bgra(),
|
|
83
|
+
}
|
|
84
|
+
try:
|
|
85
|
+
await app.native.clipboard.write_image(image)
|
|
86
|
+
except NativeError as err:
|
|
87
|
+
status.update(text=f"write failed: {err.code}")
|
|
88
|
+
return
|
|
89
|
+
status.update(text=f"wrote a {SIZE}x{SIZE} image")
|
|
90
|
+
|
|
91
|
+
async def read(ev: ui.Event) -> None:
|
|
92
|
+
try:
|
|
93
|
+
image = await app.native.clipboard.read_image("rgba")
|
|
94
|
+
except NativeError as err:
|
|
95
|
+
status.update(text=f"read failed: {err.code}")
|
|
96
|
+
return
|
|
97
|
+
if image is None:
|
|
98
|
+
status.update(text="the clipboard holds no image")
|
|
99
|
+
return
|
|
100
|
+
png = png_rgba(image["width"], image["height"], image["data"])
|
|
101
|
+
preview.update(src="data:image/png;base64," + base64.b64encode(png).decode())
|
|
102
|
+
status.update(text=f"read a {image['width']}x{image['height']} image")
|
|
103
|
+
|
|
104
|
+
with ui.Group(gap="xs"):
|
|
105
|
+
write_b = ui.Button("Write gradient", on_click=write)
|
|
106
|
+
read_b = ui.Button("Read image", on_click=read, variant="light")
|
|
107
|
+
return {"allow": allow, "status": status, "preview": preview, "write": write_b, "read": read_b}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main() -> None:
|
|
111
|
+
app = ui.AsyncApplication(
|
|
112
|
+
title="Clipboard image", width=420, height=380, profile="custom", native_allow_list=ROUTES
|
|
113
|
+
)
|
|
114
|
+
build(app)
|
|
115
|
+
asyncio.run(app.run())
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
main()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Process ids, version and port of the running application, plus restart and exit.
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/lifecycle.py [--allow-exit]
|
|
4
|
+
|
|
5
|
+
"Show" lists the runtime's process id (``app.getProcessId``), this Python
|
|
6
|
+
process id, the pinned runtime version and the configured port
|
|
7
|
+
(``app.getConfig``). "Restart" (``app.restartProcess``) and "Exit" (``app.exit``)
|
|
8
|
+
are disabled unless the example is started with ``--allow-exit``; even then each
|
|
9
|
+
asks for a confirmation first. Restart starts the runtime's own command line
|
|
10
|
+
again and exits the current one: with an application started by this SDK the
|
|
11
|
+
new process is not owned by it (see ``AsyncApplication.restart``), so it is meant
|
|
12
|
+
for a quick look, not for real use. On Linux ``app.exit`` ends the runtime
|
|
13
|
+
abnormally (ADR-005); the SDK's own shutdown is the graceful way.
|
|
14
|
+
|
|
15
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import asyncio
|
|
21
|
+
import os
|
|
22
|
+
import sys
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
from neutralino import NativeError, ui
|
|
26
|
+
|
|
27
|
+
ROUTES = ["app.getProcessId", "app.getConfig", "app.exit", "os.execCommand"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def build(
|
|
31
|
+
app: ui.AsyncApplication,
|
|
32
|
+
root: Path | None = None,
|
|
33
|
+
route: str = "/",
|
|
34
|
+
allow_exit: bool = False,
|
|
35
|
+
) -> dict[str, ui.Component]:
|
|
36
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
37
|
+
ui.Title("Lifecycle", order=3)
|
|
38
|
+
status = ui.Text("ready")
|
|
39
|
+
info = ui.Code("", block=True)
|
|
40
|
+
|
|
41
|
+
async def show(ev: ui.Event) -> None:
|
|
42
|
+
try:
|
|
43
|
+
pid = await app.native.app.get_process_id()
|
|
44
|
+
cfg = await app.native.app.get_config()
|
|
45
|
+
except NativeError as err:
|
|
46
|
+
status.update(text=f"failed: {err.code}")
|
|
47
|
+
return
|
|
48
|
+
version = app.native.runtime_info.version if app.native.runtime_info else "unknown"
|
|
49
|
+
info.update(
|
|
50
|
+
text=f"runtime pid: {pid}\npython pid: {os.getpid()}\n"
|
|
51
|
+
f"runtime version: {version}\nport: {cfg.get('port')}"
|
|
52
|
+
)
|
|
53
|
+
status.update(text="shown")
|
|
54
|
+
|
|
55
|
+
async def restart(ev: ui.Event) -> None:
|
|
56
|
+
if not await app.main_window.confirm(
|
|
57
|
+
"Restart", "Start the runtime again and exit this one?", confirm_label="Restart"
|
|
58
|
+
):
|
|
59
|
+
status.update(text="restart cancelled")
|
|
60
|
+
return
|
|
61
|
+
status.update(text="restarting")
|
|
62
|
+
try:
|
|
63
|
+
await app.native.app.restart_process()
|
|
64
|
+
except NativeError as err:
|
|
65
|
+
status.update(text=f"restart failed: {err.code}")
|
|
66
|
+
|
|
67
|
+
async def exit_now(ev: ui.Event) -> None:
|
|
68
|
+
if not await app.main_window.confirm(
|
|
69
|
+
"Exit", "Exit the application now?", confirm_label="Exit", confirm_color="red"
|
|
70
|
+
):
|
|
71
|
+
status.update(text="exit cancelled")
|
|
72
|
+
return
|
|
73
|
+
status.update(text="exiting")
|
|
74
|
+
try:
|
|
75
|
+
await app.native.app.exit()
|
|
76
|
+
except NativeError as err:
|
|
77
|
+
status.update(text=f"exit failed: {err.code}")
|
|
78
|
+
|
|
79
|
+
with ui.Group(gap="xs"):
|
|
80
|
+
show_b = ui.Button("Show", on_click=show)
|
|
81
|
+
restart_b = ui.Button(
|
|
82
|
+
"Restart", on_click=restart, variant="light", disabled=not allow_exit
|
|
83
|
+
)
|
|
84
|
+
exit_b = ui.Button(
|
|
85
|
+
"Exit", on_click=exit_now, color="red", variant="outline", disabled=not allow_exit
|
|
86
|
+
)
|
|
87
|
+
return {"status": status, "info": info, "show": show_b, "restart": restart_b, "exit": exit_b}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def main() -> None:
|
|
91
|
+
app = ui.AsyncApplication(
|
|
92
|
+
title="Lifecycle", width=520, height=360, profile="custom", native_allow_list=ROUTES
|
|
93
|
+
)
|
|
94
|
+
build(app, allow_exit="--allow-exit" in sys.argv[1:])
|
|
95
|
+
asyncio.run(app.run())
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
main()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""The runtime's locale next to Python's (``os.getLocaleInfo``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/locale.py
|
|
4
|
+
|
|
5
|
+
"Compare" shows the locale, language and region the runtime reports, the locale
|
|
6
|
+
and encoding Python resolved and the time zone names, so differences (for
|
|
7
|
+
example a runtime started with another ``LANG``) are visible side by side.
|
|
8
|
+
|
|
9
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
# This file is called locale.py, like the standard library module. Run as a script its
|
|
18
|
+
# own directory is first on sys.path, so drop it before anything imports ``locale``.
|
|
19
|
+
here = os.path.dirname(os.path.abspath(__file__)) # noqa: PTH100, PTH120
|
|
20
|
+
sys.path[:] = [p for p in sys.path if p != here]
|
|
21
|
+
|
|
22
|
+
import asyncio # noqa: E402
|
|
23
|
+
import locale as pylocale # noqa: E402
|
|
24
|
+
import time # noqa: E402
|
|
25
|
+
from pathlib import Path # noqa: E402
|
|
26
|
+
|
|
27
|
+
from neutralino import NativeError, ui # noqa: E402
|
|
28
|
+
|
|
29
|
+
ROUTES = ["os.getLocaleInfo"]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def build(
|
|
33
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
34
|
+
) -> dict[str, ui.Component]:
|
|
35
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
36
|
+
ui.Title("Locale", order=3)
|
|
37
|
+
status = ui.Text("ready")
|
|
38
|
+
out = ui.Code("", block=True)
|
|
39
|
+
|
|
40
|
+
async def compare(ev: ui.Event) -> None:
|
|
41
|
+
try:
|
|
42
|
+
info = await app.native.os.get_locale_info()
|
|
43
|
+
except NativeError as err:
|
|
44
|
+
status.update(text=f"failed: {err.code}")
|
|
45
|
+
return
|
|
46
|
+
py_locale, py_encoding = pylocale.getlocale()
|
|
47
|
+
out.update(
|
|
48
|
+
text=f"runtime locale: {info['locale']}\n"
|
|
49
|
+
f"runtime language: {info['language']}\n"
|
|
50
|
+
f"runtime region: {info['region']}\n"
|
|
51
|
+
f"python locale: {py_locale}\n"
|
|
52
|
+
f"python encoding: {py_encoding}\n"
|
|
53
|
+
f"time zone: {', '.join(time.tzname)}"
|
|
54
|
+
)
|
|
55
|
+
status.update(text="compared")
|
|
56
|
+
|
|
57
|
+
compare_b = ui.Button("Compare", on_click=compare)
|
|
58
|
+
return {"status": status, "out": out, "compare": compare_b}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main() -> None:
|
|
62
|
+
app = ui.AsyncApplication(
|
|
63
|
+
title="Locale", width=480, height=360, profile="custom", native_allow_list=ROUTES
|
|
64
|
+
)
|
|
65
|
+
build(app)
|
|
66
|
+
asyncio.run(app.run())
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
main()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""A native menu bar built from Python data (``window.setMainMenu``).
|
|
2
|
+
|
|
3
|
+
Run: uv run python examples/native/main_menu.py
|
|
4
|
+
|
|
5
|
+
"Set menu" installs the File / Edit / View menus described by ``MENU`` (a
|
|
6
|
+
list of dictionaries) with ``window.setMainMenu``; "Remove menu" installs an
|
|
7
|
+
empty one. When an item is chosen the runtime sends ``mainMenuItemClicked``
|
|
8
|
+
with the item's id, text and state and the page logs it. The pinned runtime
|
|
9
|
+
sends that event on macOS menus only (``contracts/events.json``); on Linux the
|
|
10
|
+
menu is shown but clicks do not reach the event, and on Windows there is no
|
|
11
|
+
menu support in this version. ``Window.set_main_menu`` of the runtime's client
|
|
12
|
+
is the same call.
|
|
13
|
+
|
|
14
|
+
``ROUTES`` is the exact native allow list this example needs.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import asyncio
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
from neutralino import NativeError, ui
|
|
23
|
+
from neutralino.api.types import WindowMenuItem
|
|
24
|
+
from neutralino.events import Event
|
|
25
|
+
|
|
26
|
+
ROUTES = ["window.setMainMenu"]
|
|
27
|
+
MENU: list[WindowMenuItem] = [
|
|
28
|
+
{
|
|
29
|
+
"id": "file",
|
|
30
|
+
"text": "File",
|
|
31
|
+
"menuItems": [
|
|
32
|
+
{"id": "new", "text": "New", "shortcut": "n"},
|
|
33
|
+
{"id": "open", "text": "Open", "shortcut": "o"},
|
|
34
|
+
{"text": "-"},
|
|
35
|
+
{"id": "quit", "text": "Quit", "shortcut": "q"},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "edit",
|
|
40
|
+
"text": "Edit",
|
|
41
|
+
"menuItems": [
|
|
42
|
+
{"id": "undo", "text": "Undo", "shortcut": "z"},
|
|
43
|
+
{"id": "redo", "text": "Redo", "isDisabled": True},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "view",
|
|
48
|
+
"text": "View",
|
|
49
|
+
"menuItems": [{"id": "wrap", "text": "Word wrap", "isChecked": True}],
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def build(
|
|
55
|
+
app: ui.AsyncApplication, root: Path | None = None, route: str = "/"
|
|
56
|
+
) -> dict[str, ui.Component]:
|
|
57
|
+
lines: list[str] = []
|
|
58
|
+
subscribed: list[bool] = []
|
|
59
|
+
|
|
60
|
+
with app.page(route), ui.Stack(gap="xs"):
|
|
61
|
+
ui.Title("Main menu", order=3)
|
|
62
|
+
status = ui.Text("no menu set")
|
|
63
|
+
log = ui.Code("", block=True)
|
|
64
|
+
|
|
65
|
+
def on_click(event: Event) -> None:
|
|
66
|
+
d = event.data
|
|
67
|
+
if isinstance(d, dict):
|
|
68
|
+
lines.append(f"clicked {d['id']} ({d['text']})")
|
|
69
|
+
log.update(text="\n".join(lines[-20:]))
|
|
70
|
+
|
|
71
|
+
async def install(items: list[WindowMenuItem]) -> None:
|
|
72
|
+
if not subscribed:
|
|
73
|
+
app.native.events.on("mainMenuItemClicked", on_click)
|
|
74
|
+
subscribed.append(True)
|
|
75
|
+
try:
|
|
76
|
+
await app.native.window.set_main_menu(items)
|
|
77
|
+
except NativeError as err:
|
|
78
|
+
status.update(text=f"menu failed: {err.code}")
|
|
79
|
+
return
|
|
80
|
+
status.update(text=f"menu set with {len(items)} top-level entries")
|
|
81
|
+
|
|
82
|
+
async def set_menu(ev: ui.Event) -> None:
|
|
83
|
+
await install(MENU)
|
|
84
|
+
|
|
85
|
+
async def remove_menu(ev: ui.Event) -> None:
|
|
86
|
+
await install([])
|
|
87
|
+
|
|
88
|
+
with ui.Group(gap="xs"):
|
|
89
|
+
set_b = ui.Button("Set menu", on_click=set_menu)
|
|
90
|
+
remove_b = ui.Button("Remove menu", on_click=remove_menu, variant="light")
|
|
91
|
+
return {"status": status, "log": log, "set": set_b, "remove": remove_b}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def main() -> None:
|
|
95
|
+
app = ui.AsyncApplication(
|
|
96
|
+
title="Main menu", width=460, height=340, profile="custom", native_allow_list=ROUTES
|
|
97
|
+
)
|
|
98
|
+
build(app)
|
|
99
|
+
asyncio.run(app.run())
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if __name__ == "__main__":
|
|
103
|
+
main()
|