FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs(mkdocs): add preview API reference page by andevsr · Pull Request #71 · pythonnative/pythonnative · GitHub

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (2) .py  (1) .yml  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
19 changes: 19 additions & 0 deletions docs/api/preview.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Preview

The desktop preview is the engine behind `pn preview`: it renders an
app in a real OS window through the Tkinter backend, with Fast
Refresh on every save. [`run_preview`][pythonnative.preview.run_preview]
opens the window and runs until it closes, and
[`DesktopApp`][pythonnative.preview.DesktopApp] owns the navigation
stack inside it.

::: pythonnative.preview
options:
show_root_heading: false
show_root_toc_entry: false
members_order: source
filters: ["!^_"]

## Next steps

- See the workflow in the [Desktop preview guide](../guides/desktop-preview.md).
2 changes: 1 addition & 1 deletion docs/guides/desktop-preview.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ No other dependencies are required; the desktop backend is pure Python.
## How it works

`pn preview` sets `PN_PLATFORM=desktop` and starts
`pythonnative.preview.run_preview`, which:
[`run_preview`](../api/preview.md), which:

1. Opens a single Tk window with one *stage* frame.
2. Selects the Tkinter
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ nav:
- Platform metrics: api/platform_metrics.md
- SDK: api/sdk.md
- Hot reload: api/hot_reload.md
- Preview: api/preview.md
- Diagnostics: api/diagnostics.md
- Utilities: api/utils.md
- CLI (pn): api/cli.md
Expand Down
6 changes: 3 additions & 3 deletions src/pythonnative/preview.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Desktop preview runtime, the engine behind ``pn preview``.

``pn preview`` renders a PythonNative app in a real OS window using the
Tkinter backend ([`pythonnative.native_views.desktop`][pythonnative.native_views.desktop]),
Tkinter backend (``pythonnative.native_views.desktop``),
with **instant Fast Refresh** on every file save. It exists to make the
inner development loop fast: see your UI and iterate in seconds without
booting a simulator or deploying to a device.
Expand All @@ -12,7 +12,7 @@
navigation stack gets its own child container inside the stage; the
desktop view handlers create widgets under the active container.
- [`DesktopApp`][pythonnative.preview.DesktopApp] owns the navigation
stack of [`screen`][pythonnative.screen] hosts and the push/pop/reset
stack of ``pythonnative.screen`` hosts and the push/pop/reset
primitives the declarative navigators call through ``host._push`` /
``host._pop``.
- The Tk event loop runs on the main thread. A lightweight poll
Expand Down Expand Up @@ -77,7 +77,7 @@ class DesktopApp:
"""Navigation-stack controller for the desktop preview window.

One instance backs a preview session. It is handed to each
[`screen`][pythonnative.screen] host as the ``native_instance`` so
[``create_screen``][pythonnative.create_screen] host as the ``native_instance`` so
hosts can drive navigation (``push_screen`` / ``pop_screen`` /
``reset_to_root``), report the viewport size, and set the window
title, mirroring the role a ``UIViewController`` / ``Activity``
Expand Down

Back | FazBrowse Home | New Git URL