Skip to content

Open a Web GUI Project in Python

Download notebook (.zip)

From PhotonForge 2.2, the web GUI shows your projects, but you cannot edit them there. To edit a project, load it in Python and show it in the local GUI.

In this notebook, you will learn how to:

  • Find a web GUI project by its name.
  • Load the project in Python.
  • Show a component of the project in the local GUI.
  • Save your changes to the project.

You need PhotonForge 2.2 or newer and your Tidy3D API key (tidy3d configure). To install PhotonForge, see Installation.

The Projects page of the web GUI lists your projects. This notebook uses the project LiveViewer edit demo.

Projects in the web GUI

Click the project. The Components tab shows the components of the project.

Components of the project

Click a component. The Overview tab shows its schematic and its layout. You can look at them, but you cannot edit them.

A component in the web GUI

Remember the name of the project. You use it in step 3.

Import the PDA module and the local GUI. pda.init connects to your projects with your Tidy3D API key.

import photonforge.pda as pda
from photonforge.live_viewer import LiveViewer
pda.init()

If pda.init() fails with CERTIFICATE_VERIFY_FAILED on macOS, your Python from python.org does not have its root certificates yet. To install them, run the Install Certificates.command that is in the folder of your Python version in Applications:

Terminal window
open "/Applications/Python 3.12/Install Certificates.command"

Change 3.12 to your Python version, then restart the notebook kernel. For more information, see Installation steps in the Python documentation.

Put the name of your project in PROJECT_NAME. pda.list_projects lists the projects that you can open. It opens each project to read its name, so it takes approximately 0.3 s for each project.

PROJECT_NAME = "LiveViewer edit demo"
projects = pda.list_projects()
# Keep the projects with this name
matches = [p for p in projects if p["name"] == PROJECT_NAME]
if not matches:
raise ValueError(f"No project has the name {PROJECT_NAME!r}")
for p in matches:
print(p["createdAt"][:10], p["documentId"])
2026-11-23 32ME6QdFduCK7TacvwnVAcNpGNzw

Two projects can have the same name. This code loads the newest one with pda.load_project.

newest = max(matches, key=lambda p: p["createdAt"])
project = pda.load_project(project_id=newest["documentId"])
# Show the names of the components in the project
list(project.components(origin="self"))
['Coupler', 'MZI', 'Straight 20 um']

load_project sets the technology of the project as the default technology. It also writes the Python code of the project in a pflibs folder in the working directory.

A schematic that you saved in the old web GUI is a component of the project. The old web GUI gave it the name Component if you did not change the name. A schematic that you did not save is not in this list.

Project.component gets a component by its name. The local GUI runs on your computer, not in the cloud.

# Use a name from the list above
component = project.component("MZI")
# Start the local GUI on port 8841 and show the component
viewer = LiveViewer(port=8841)
viewer(component)
LiveViewer started at http://127.0.0.1:8841. Call its 'stop()' method to free the port.
Layout
Schematic
Netlist

Open http://localhost:8841 in your browser. To edit the component in the local GUI, see Quick Start I: Local GUI.

The local GUI changes component in your Python session. Project.update saves it to the project, and the web GUI shows the changes.

CAUTION: project.update writes your copy of the component over the copy in the project. If a teammate saved the same component after you loaded the project, their changes are lost.

project.update(viewer.component)
print("Saved", viewer.component.name)
Saved MZI
viewer.stop()
pda.stop()
LiveViewer stopped; port 8841 is free.