| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
The smallest possible PythonNative app. You'll learn how to:
Save this as app/main.py:
import pythonnative as pn
@pn.component
def App():
count, set_count = pn.use_state(0)
return pn.Column(
pn.Text(f"Count: {count}", style={"font_size": 24, "bold": True}),
pn.Button("Tap me", on_press=lambda: set_count(count + 1)),
style={"spacing": 12, "padding": 16, "align_items": "stretch"},
)For the fastest feedback loop, start the dev server and open the browser preview before reaching for an emulator or simulator. The preview imports your real app code, so if your project declares packages in [requirements].packages, pip install them first (this example needs emoji). From the project root:
pn previewA browser tab opens with app/main.py's App in a phone frame. Edit a component, save, and the preview refreshes in place. See the Browser preview guide for the toolbar and more options.
Leave pn preview running and, from the project root in another terminal:
pn run android # or: pn run iospn run will:
The app is now a dev client: saves under app/ Fast Refresh it, and its output shows up in the pn preview terminal. See the Development workflow for the details.
| Back | FazBrowse Home | New Git URL |