### Setup and Run Bike CFD Example
Source: https://github.com/kitware/trame/blob/master/examples/06_vtk/04_wasm/README.md
These commands set up a Python virtual environment, install dependencies, and run the CFD bike simulation application.
```bash
python -m venv .venv
```
```bash
source .venv/bin/activate
```
```bash
pip install -r ./requirements.txt
```
```bash
python ./app.py
```
--------------------------------
### Setup Server Relay
Source: https://github.com/kitware/trame/blob/master/examples/validation/relay/server_sink/README.md
Commands to set up a virtual environment, install trame, generate static content, and start the wslink relay server.
```bash
# Working directory
mkdir -p test-relay && cd "$_"
# Virtual environment setup
python -m venv .venv
source ./.venv/bin/activate
pip install -U pip trame
# Generate static content
python -m trame.tools.www --output ./www
# Start relay
python -m wslink.relay --www ./www --mode relay
```
--------------------------------
### Run Default Trame Serve Example
Source: https://github.com/kitware/trame/blob/master/docs/api/source/tools.serve.rst
Execute the default trame application demo using the serve utility. This command starts a trame server with default configurations.
```bash
python -m trame.tools.serve
```
--------------------------------
### Setup Relay Environment
Source: https://github.com/kitware/trame/blob/master/examples/validation/relay/forward/README.md
Installs necessary packages and generates static content for the relay. Ensure you are in the correct working directory and have activated your virtual environment.
```bash
mkdir -p test-relay && cd "$_"
python -m venv .venv
source ./.venv/bin/activate
pip install -U pip trame
python -m trame.tools.www --output ./www
python -m wslink.relay --www ./www
```
--------------------------------
### Install Documentation Requirements
Source: https://github.com/kitware/trame/blob/master/docs/api/README.md
Install the necessary Python packages for building documentation. Ensure you are in the 'docs/' directory.
```bash
pip install -r requirements.txt
```
--------------------------------
### Run Example Simulation with Catalyst
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/monitor-your-simulation-in-your-web-browser-with-trame-and-catalyst.md
Download necessary Python modules and set environment variables for Catalyst. Then, launch the example simulation using uv run.
```shell
# Download the extra python modules needed to run the simulation
uv sync --extra simulation
# Setup environment variables for the simulation
export CATALYST_IMPLEMENTATION_PATHS=/path/to/paraview/lib/catalyst
export PYTHONPATH=/path/to/catalyst/lib/python3.14/site-packages/
# Launch the example simulation
uv run src/trame_catalyst_demo/example/fedriver.py src/trame_catalyst_demo/example/pipeline.py
```
--------------------------------
### Annonce Component Example
Source: https://github.com/kitware/trame/blob/master/examples/09_advanced/tailwind/content.html
Demonstrates how to use the Annonce component with primary intent for new announcements. Ensure the 'tailus-ui' package is installed.
```javascript
import Annonce from "tailus-ui/Annonce"; export default () => { return ( New Say hello to the new Tailus ! ) };
```
--------------------------------
### Trame Environment Setup and Dependencies
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/vtk-9-4-a-step-closer-to-the-ways-of-python.md
This section provides the necessary commands to set up a Python virtual environment and install the required packages for running Trame applications with VTK. Ensure you have a VTK version of 9.4.0rc2 or later.
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install trame trame-vtk trame-vuetify
pip install "vtk>=9.4.0rc2" --extra-index-url https://wheels.vtk.org
# Fetch demo code
curl -O https://raw.githubusercontent.com/Kitware/trame/refs/heads/master/examples/blogs/vtk-9.4/pipeline.py
```
--------------------------------
### Run Simple Example App
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/desktop.md
Execute a simple example Trame application using the command-line interface. This is useful for testing Trame's application bundling capabilities.
```bash
python -m trame.app.demo --app
```
--------------------------------
### Install Trame with pip
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/pypi.md
Installs the main Trame package along with common widget libraries for client-server applications. Use this to run the simple example app.
```bash
pip install \
trame \
trame-vuetify \
trame-vtk
# Run simple example app
python -m trame.app.demo
```
--------------------------------
### Start Trame Server
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/layouts.md
Define the main function to instantiate the TrameApp and start the server using app.server.start(). This is the entry point for running the application.
```python
def main():
app = ConeApp()
app.server.start()
if __name__ == "__main__":
main()
```
--------------------------------
### Install Trame and Run Standalone App
Source: https://github.com/kitware/trame/blob/master/examples/validation/panel/README.md
Installs necessary Trame packages and starts a standalone Trame application. Ensure you have the correct Python environment activated.
```bash
pip install trame trame-quasar trame-vtk
python ./app_trame.py
```
--------------------------------
### Run Trame Vedo Example with uv
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/faster-simpler-python-application-execution-with-uv-and-trame.md
Execute a Trame application ported from a Vedo example, using plain VTK and Trame, directly from a URL with uv.
```bash
uv run https://raw.githubusercontent.com/Kitware/vtk-scene/refs/heads/main/examples/grayscott.py
```
--------------------------------
### Start Trame Launcher
Source: https://github.com/kitware/trame/blob/master/examples/validation/launcher/README.md
Initializes a log directory and starts the Trame launcher using a configuration file.
```bash
mkdir -p viz-logs
python -m wslink.launcher ./config.json
```
--------------------------------
### Basic Shell Script Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/sample.md
A simple shell script example demonstrating a loop.
```shell
# Let me re-iterate ...
for i in 1 .. 10 { do-something(i) }
```
--------------------------------
### Setup and Run Trame Application
Source: https://github.com/kitware/trame/blob/master/examples/07_paraview/Wavelet/README.md
This bash script sets up a Python virtual environment, installs necessary packages (trame, trame-rca), and then runs the application using the specified Python interpreter.
```bash
python3.9 -m venv .pv_venv
source ./.pv_venv/bin/activate
pip install -U pip
pip install trame trame-rca
export PV_VENV=$PWD/.pv_venv
$PV_PYTHON ./app.py
```
--------------------------------
### Instantiate and Start Trame Application
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/setup.md
Define the main function to create an instance of the application and start the server. The port can be specified via command-line arguments.
```python
def main():
app = App()
app.server.start()
if __name__ == "__main__":
main()
```
--------------------------------
### Install Panel and Serve Standalone App
Source: https://github.com/kitware/trame/blob/master/examples/validation/panel/README.md
Installs the Panel library and serves a Panel application from a Python script. This is for deploying Panel applications as standalone web services.
```bash
pip install panel
panel serve ./app_panel.py
```
--------------------------------
### Execute ParaView Example with pvpython and Virtual Environment
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/paraview.md
Run a ParaView Python script using 'pvpython' and specify a virtual environment for execution. This is common for ParaView installations on macOS.
```bash
/Applications/ParaView-6.1.0.app/Contents/bin/pvpython \
--venv .pvenv \
./05_paraview/SimpleCone.py
```
--------------------------------
### Run VTK Pipeline Example
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/vtk-9-4-a-step-closer-to-the-ways-of-python.md
Execute the main Python script to launch the interactive VTK application.
```bash
python ./pipeline.py
```
--------------------------------
### Initialize Trame Server
Source: https://github.com/kitware/trame/blob/master/examples/jupyter/webinar/gui.ipynb
Sets up the Trame server instance for a new GUI application. This is the starting point for any Trame application.
```python
from trame.app import get_server
from trame.ui.vuetify3 import VAppLayout
from trame.widgets import html
from trame.widgets import vuetify3 as v3
server = get_server("my_gui_demo")
```
--------------------------------
### C Programming Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/demo.md
A basic 'Hello, World!' program in C. This snippet demonstrates standard C syntax and output.
```c
#include
int main(int argc char* argv[]) {
printf("Hello, World!");
return 0;
}
```
--------------------------------
### Install JupyterLab and Trame Manager
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/jupyterlab-trame-manager-at-julich-supercomputing-centre.md
Install JupyterLab and the jupyterlab-trame-manager extension using pip. This is the initial step for setting up the environment.
```bash
pip install jupyterlab jupyterlab-trame-manager
```
--------------------------------
### Install Trame and Related Libraries
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/trame-revolutionizing-visual-analytics-with-python.md
Install trame and its essential extensions for Vuetify and VTK using pip. This is the first step to begin building trame applications.
```bash
pip install trame trame-vuetify trame-vtk
```
--------------------------------
### Install Trame and Dependencies
Source: https://github.com/kitware/trame/blob/master/examples/07_paraview/Picking/README.md
Set up a local Python virtual environment and install the required Trame packages and their dependencies. Ensure you are using a compatible Python version.
```bash
python3.9 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install trame trame-vtk trame-vuetify
export PV_VENV=$PWD/.venv
```
--------------------------------
### Install Trame and Dependencies with uv
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/setup.md
Use uv to create a Python 3.12 virtual environment and install Trame, Vuetify widgets, and VTK.
```bash
uv venv -p 3.12
source ./.venv/bin/activate
uv pip install trame # Install trame core
uv pip install trame-vuetify trame-vtk # Install widgets that we'll be using
uv pip install vtk # Install the VTK library
```
--------------------------------
### Setup ParaView Python Environment
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/paraview.md
Create a virtual environment, activate it, upgrade pip, install Trame and related packages, and then deactivate the environment. This process is essential for using Trame with ParaView.
```bash
python3.12 -m venv .pvenv
source ./.pvenv/bin/activate
python -m pip install --upgrade pip
pip install trame trame-vtk trame-vuetify
deactivate
```
--------------------------------
### Start Jupyter Lab
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/jupyter/intro.md
Launch the Jupyter Lab environment from your terminal. This command starts the server and opens the interface in your browser.
```bash
jupyter lab
```
--------------------------------
### Install Trame Components
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/application.md
Install the `trame-components` package to enable the use of predefined Trame widgets for visualization and interaction.
```sh
pip install trame-components
```
--------------------------------
### Install Trame and Demo App Requirements
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/desktop.md
Install the necessary packages for Trame applications and the demo app. This includes the core Trame library with app support, trame-vuetify, and trame-vtk.
```bash
pip install "trame[app]" trame-vuetify trame-vtk # Demo app requirement
```
--------------------------------
### Install Dependencies for VTK.wasm and Trame
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/vtk-wasm-and-its-trame-integration.md
Set up a virtual environment and install necessary packages including trame, trame-vtklocal, and VTK. Ensure you are using the correct VTK version for compatibility.
```bash
python -m venv .venv
source .venv/bin/activate
pip install trame trame-vtklocal
pip install "vtk==9.4.0rc2" --extra-index-url https://wheels.vtk.org
```
--------------------------------
### Run Application
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/layouts.md
Execute the Python script from the command line to start the Trame application. Specify the port using the --port argument.
```bash
python 02_layouts/app_cone.py --port 1234
# or
python 02_layouts/solution_FullScreenPage.py --port 1234
```
--------------------------------
### JSON Configuration Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/demo.md
A simple JSON object, often used for configuration or data exchange. Ensure valid JSON syntax.
```json
{
"name": "markdown-it-vue"
}
```
--------------------------------
### Start and Display Trame Application in Jupyter
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/jupyter.md
Instantiate the Trame application class and await its UI readiness before displaying it within the Jupyter environment.
```python
cone = Cone()
await cone.ui.ready
cone.ui
```
--------------------------------
### Create and Activate Trame Virtual Environment
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/blogs/exposing-web-application-with-paraview-5-13-is-getting-simpler.md
Use these commands to create a Python virtual environment, activate it, install Trame components, and then deactivate it.
```bash
python3.10 -m venv .venv
source .venv/bin/activate
pip install paraview-trame-components
deactivate
```
--------------------------------
### Install Trame with conda
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/pypi.md
Installs Trame and associated widget libraries from the conda-forge channel. This command also includes instructions to run the simple example app.
```bash
conda install \
-c conda-forge \
trame \
trame-vuetify \
trame-vtk
# Run simple example app
python -m trame.app.demo
```
--------------------------------
### Install Trame and Jupyter Dependencies
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/jupyter/intro.md
Install necessary Python packages for Trame, VTK, Vuetify, and JupyterLab. This setup is required before running Trame applications in a Jupyter environment.
```bash
python3 -m venv .venv
source .venv/bin/activate # => Linux / Mac
# .\.venv\Scripts\activate # => Window
pip install trame trame-vtk trame-vuetify
pip install jupyterlab
```
--------------------------------
### Clone Trame Tutorial Repository
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/download.md
Use this command to download the Trame tutorial project files from GitHub. The tutorial steps assume you are in the root directory of this cloned project.
```bash
git clone https://github.com/Kitware/trame-tutorial.git
```
--------------------------------
### Start VTK Rendering Info Trame Application
Source: https://github.com/kitware/trame/blob/master/docs/api/source/tools.vtk.rst
Execute this command to launch the VTK rendering information tool as a standalone trame application. This provides an interactive interface for exploring rendering capabilities.
```bash
python -m trame.tools.vtk
```
--------------------------------
### Install Trame
Source: https://github.com/kitware/trame/blob/master/README.rst
Install or upgrade trame using pip. This command installs the core infrastructure for trame applications.
```bash
pip install --upgrade trame
```
--------------------------------
### Install VTK for EGL
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/deployment/docker.md
Install the VTK wheel specifically built for EGL, which is recommended for offscreen rendering in Docker environments. This replaces the default VTK and VTK-OSMesa installations.
```bash
pip uninstall vtk vtk-osmesa
pip install --extra-index-url https://wheels.vtk.org vtk-egl
```
--------------------------------
### Install Trame Requirements
Source: https://github.com/kitware/trame/blob/master/examples/validation/launcher/README.md
Installs the necessary Trame packages and their dependencies using pip.
```bash
pip install trame trame-vtk trame-vuetify trame-components vtk
```
--------------------------------
### Initialize ParaView Pipeline with Simple API
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/paraview.md
Demonstrates the basic usage of ParaView's `simple` API to create a cone source, display it, and render the scene. This is a core part of setting up a ParaView visualization pipeline.
```python
from paraview import simple
# [...]
class ConeApp(TrameApp):
# [...]
def _init_paraview(self):
self.cone = simple.Cone() # Create a source (reader, filter...)
self.representation = simple.Show(cone) # Create a representation in a view (if no view, one is created)
self.view = simple.Render() # Ask to compute image of active view and return the corresponding view
```
--------------------------------
### Bash Installation Command
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/demo.md
The command to install the markdown-it-vue package using npm. This is a standard bash command for package management.
```bash
npm install markdown-it-vue
```
--------------------------------
### Serve Application with Multiple Users (Bash)
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/versions/features.md
Provides a command-line example for serving a Trame application to multiple users from a single process using the `trame.tools.serve` module. This is useful for scenarios requiring shared application instances.
```bash
# Assuming the code from 3.1 exist in a MyApp.py file
# you can run it with the following command line
python -m trame.tools.serve --exec MyApp:App
```
--------------------------------
### Build UI with SinglePageLayout and Components
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/html.md
Demonstrates building a UI with `SinglePageLayout`, including a `VSwitch` for theme toggling and a `VBtn` for resetting the camera view. The `theme` state variable controls the application's theme.
```python
from trame.app import TrameApp
from trame.ui.vuetify import SinglePageLayout
from trame.tools import client
import vtk
import trame.ui.vuetify as v3
class AppButtons(TrameApp):
# [...]
def _build_ui(self):
# Use state variable `theme` for the theme with default value 'light'
with SinglePageLayout(self.server, theme=("theme", "light")) as self.ui:
with self.ui.content:
with v3.VContainer(
fluid=True,
classes="pa-0 fill-height",
):
self.view = vtk.VtkLocalView(self.renderWindow)
self.server.ctrl.on_server_ready.add(self.view.update)
self.server.ctrl.view_update = self.view.update # <-- Capture update method (will be useful later)
ctrl.view_reset_camera = self.view.reset_camera # <-- Capture reset_camera method
with self.ui.toolbar:
v3.VSpacer()
v3.VSwitch(
v_model="theme",
false_value="light", # <-- Value of v_model's variable if switch toggled off
true_value="dark", # <-- Value of v_model's variable if switch toggled on
hide_details=True,
density="compact",
)
v3.VBtn(
icon="mdi-crop-free",
click=self.ctrl.view_reset_camera, # <-- Use that reset_camera (init order does not matter)
)
```
--------------------------------
### Initialize VTK and Trame Server
Source: https://github.com/kitware/trame/blob/master/examples/validation/jupyter/multi-views.ipynb
Sets up the necessary VTK rendering pipeline and initializes the Trame server. Includes event handlers for server readiness and exit, and a function to update VTK object properties based on state changes.
```python
import vtkmodules.vtkRenderingOpenGL2 # noqa
from vtkmodules.vtkFiltersSources import vtkConeSource
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleSwitch # noqa
from vtkmodules.vtkRenderingCore import (
vtkActor,
vtkPolyDataMapper,
vtkRenderer,
vtkRenderWindow,
vtkRenderWindowInteractor,
)
from trame.app import get_server, jupyter
from trame.ui.vuetify import SinglePageLayout, VAppLayout
from trame.widgets import trame, vtk, vuetify
# VTK -----------------------------------------------------
DEFAULT_RESOLUTION = 6
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
cone_source = vtkConeSource()
mapper = vtkPolyDataMapper()
actor = vtkActor()
mapper.SetInputConnection(cone_source.GetOutputPort())
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renderWindow.Render()
# Trame ---------------------------------------------------
server = get_server(client_type="vue2")
state, ctrl = server.state, server.controller
def reset_resolution():
state.resolution = 6
@state.change("resolution")
def update_resolution(resolution, **kwargs):
cone_source.SetResolution(int(resolution))
ctrl.view_update()
ctrl.on_server_ready.add(lambda **_: print("Ready"))
ctrl.on_server_exited.add(lambda **_: print("Exited"))
ctrl.on_server_ready.add(ctrl.view_update)
```
--------------------------------
### Initialize Trame Application
Source: https://github.com/kitware/trame/blob/master/examples/validation/panel/trame.ipynb
Instantiate and prepare the Trame application. Ensure the UI is ready before accessing it.
```python
from app_trame import StHelens
app = StHelens()
await app.ui.ready
app.ui
```
--------------------------------
### Generate Custom Application HTML
Source: https://github.com/kitware/trame/blob/master/docs/api/source/tools.app.rst
Use this command-line tool to create a new HTML file that launches a specific application. Provide the input directory containing the base web client output and the name for your new application.
```bash
python -m trame.tools.app --input ./www-content --name MySuperApp
# => create file MySuperApp.html from ./www-content/index.html
```
--------------------------------
### Configure Drawer UI Components
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/application.md
Set up the application's drawer, including its width and the Trame pipeline widget, a vertical divider, and pipeline-specific cards.
```python
with self.ui.drawer as drawer:
# drawer components
drawer.width = 325
self.pipeline_widget()
v3.VDivider(classes="mb-2")
mesh_card()
contour_card()
```
--------------------------------
### Install Trame Dependencies in Google Colab
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/jupyter/intro.md
Install Trame, VTK, and Vuetify packages quietly within a Google Colab notebook. The `%%capture` magic command suppresses output.
```jupyter
%%capture --no-stderr
!pip install -q --upgrade trame trame-vtk trame-vuetify
```
--------------------------------
### Initialize VTK Rendering Pipeline
Source: https://github.com/kitware/trame/blob/master/examples/validation/jupyter/remote-rendering.ipynb
Sets up the basic VTK rendering pipeline including renderer, render window, interactor, cone source, mapper, and actor. This forms the foundation for the 3D visualization.
```python
DEFAULT_RESOLUTION = 6
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
cone_source = vtkConeSource()
mapper = vtkPolyDataMapper()
actor = vtkActor()
mapper.SetInputConnection(cone_source.GetOutputPort())
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renderWindow.Render()
```
--------------------------------
### Create and Display First UI Element
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/jupyter/sample-code.md
Initialize a Trame server, define state change handlers, and create the first UI component (a slider) using `DivLayout`. The UI is then displayed in the Jupyter cell.
```python
from trame.app import get_server
from trame.widgets import html
from trame.ui.html import DivLayout
server = get_server()
state = server.state
def reset_slider():
state.slider_a = 2
@state.change("slider_a")
def udpate_result(slider_a, **_):
state.result = slider_a / 2
with DivLayout(server, 'a', height=30) as ui_a:
html.Input(
type="range",
min=-1,
max=50,
step=0.1,
v_model_number=("slider_a", 2),
style="width: 100%;",
)
await ui_a.display_cell()
```
--------------------------------
### Python Time Sleep Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/sample.md
A Python script that counts to ten with a delay between each number.
```python
import time
# Quick, count to ten!
for i in range(10):
# (but not *too* quick)
time.sleep(0.5)
print i
```
--------------------------------
### Configure Second Trame Server and UI
Source: https://github.com/kitware/trame/blob/master/examples/validation/jupyter/remote-rendering.ipynb
Sets up a second Trame server instance with its own state and controller, and defines a similar UI layout but using VtkView and VtkAlgorithm for a more declarative approach to VTK object definition.
```python
# -----------------------------------------------------------------------------
# Trame setup
# -----------------------------------------------------------------------------
s2 = get_server("jupyter-2", client_type="vue2")
state2, ctrl2 = s2.state, s2.controller
def reset_resolution_2():
state2.resolution = 6
ctrl2.reset_resolution = reset_resolution_2
# -----------------------------------------------------------------------------
# UI setup
# -----------------------------------------------------------------------------
layout2 = SinglePageLayout(s2)
with layout2:
# Validate client life cycle
trame.LifeCycleMonitor(events=("['created']",))
layout2.icon.click = ctrl2.reset_camera
layout2.title.set_text("Cone")
layout2.toolbar.dense = True
# Toolbar
with layout2.toolbar as toolbar:
vuetify.VSpacer()
vuetify.VSlider(
hide_details=True,
v_model=("resolution", 6),
max=60,
min=3,
step=1,
style="max-width: 300px;",
)
vuetify.VSwitch(
hide_details=True,
v_model=("$vuetify.theme.dark",),
)
with vuetify.VBtn(icon=True, click=ctrl2.reset_resolution):
vuetify.VIcon("mdi-undo")
with layout2.content:
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
with vtk.VtkView() as view:
ctrl2.reset_camera = view.reset_camera
with vtk.VtkGeometryRepresentation():
vtk.VtkAlgorithm(
vtk_class="vtkConeSource", state=ירת("{ resolution }",)
)
```
--------------------------------
### Basic Define Function Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/sample.md
A basic function definition in an unspecified scripting language.
```script
define foobar() {
print "Welcome to flavor country!";
}
```
--------------------------------
### Load ParaView state file and set up view
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/tutorial/paraview.md
Loads a ParaView state file using `simple.LoadState` and retrieves the active view. It also configures the view's render window interactor and triggers an initial render.
```python
class StateLoaderApp(TrameApp):
# [...]
def load_data(self, **_):
# [...]
simple.LoadState(
full_path,
data_directory=working_directory,
restrict_to_data_directory=True,
)
self.view = simple.GetActiveView()
self.view.MakeRenderWindowInteractor(True)
simple.Render(self.view)
```
--------------------------------
### get(key=null)
Source: https://github.com/kitware/trame/blob/master/docs/api/source/client.intro.rst
Retrieves the value of a state variable. If no key is provided, the entire state is returned as a dictionary.
```APIDOC
## get(key=null)
Given a variable name, its value will be returned. If nothing is provided, the full state will be returned as a dictionary.
### Parameters
#### Path Parameters
- **key** (str) - The name of the state variable to retrieve
### Returns
- (any) - Return the value stored within that state variable or the full state object.
```
--------------------------------
### ASCIIMath Rendering
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/demo.md
Provides examples of ASCIIMath for rendering mathematical formulas. Use the `ASCIIMath` language identifier for these blocks.
```ASCIIMath
oint_Cx^3 dx+4y^2 dy
2=(((3-x)xx2)/(3-x))
sum_(m=1)^oosum_(n=1)^oo(m^2 n)/(3^m(m3^n+n3^m)
```
```ASCIIMath
phi_n(kappa) = 1/(4pi^2 kappa^2)
int_0^oo (sin(kappa R))/(kappa R)
del/(del R)
[R^2 (del D_n (R))/(del R)] del R
```
--------------------------------
### Trame Application Entrypoint
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/examples/core/docker.md
The main Python script for a Trame application, demonstrating a simple VTK rendering example.
```python
from trame.app import get_app
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vtk
app = get_app()
ui = SinglePageLayout(app,)
ui.title = "Trame Cone"
ui.content.children = [
vtk.VtkView(id="vtk-view")
]
if __name__ == "__main__":
app.run()
```
--------------------------------
### Start Test Process
Source: https://github.com/kitware/trame/blob/master/examples/validation/relay/forward/README.md
Runs a Trame application as a test process on a specific port. This process will be forwarded to by the relay.
```bash
python $TRAME_ROOT/examples/06_vtk/01_SimpleCone/RemoteRendering.py --server --port 1234
```
--------------------------------
### JavaScript Import Example
Source: https://github.com/kitware/trame/blob/master/examples/03_markdown/demo.md
Shows how to import and register the MarkdownItVue component in a JavaScript project. This is typically used in frontend frameworks.
```javascript
import MarkdownItVue from 'markdown-it-vue'
export default {
components: {
MarkdownItVue
}
}
```
--------------------------------
### Instantiate and Display Trame App
Source: https://github.com/kitware/trame/blob/master/docs/vitepress/guide/jupyter/how-it-works.md
Instantiate the application, wait for the UI to be ready, and then display it in the cell output. This code is typically run within a Jupyter environment.
```python
from module import App # Get the application class
app = App() # a) Instantiate application (with default server)
await app.ui.ready # b) Wait for the UI to be ready
app.ui # c) Display UI in cell output
```