class_docstr: A frontend for wrapping JustPy code in your LightingFlow.
  
  Return this in your `LightningFlow.configure_layout()` method if you wish to build the UI with ``justpy``.
  To use this frontend, you must first install the `justpy` package (if running locally):
  
  .. code-block:: bash
  
      pip install justpy
  
  Arguments:
      render_fn: A function that contains your justpy code. This function must accept exactly one argument, the
          ``AppState`` object which you can use to access variables in your flow (see example below).
  
  Example:
  
      In your LightningFlow, override the method `configure_layout`:
  
      .. code-block:: python
  
          from typing import Callable
          from lightning import LightningApp, LightningFlow
          from lightning.app.frontend import JustPyFrontend
  
  
          class Flow(LightningFlow):
              def __init__(self):
                  super().__init__()
                  self.counter = 0
  
              def run(self):
                  print(self.counter)
  
              def configure_layout(self):
                  return JustPyFrontend(render_fn=render_fn)
  
  
          def render_fn(get_state: Callable) -> Callable:
              import justpy as jp
  
              def my_click(self, *_):
                  state = get_state()
                  old_counter = state.counter
                  state.counter += 1
                  self.text = f"Click Me ! Old Counter: {old_counter} New Counter: {state.counter}"
  
              def webpage():
                  wp = jp.WebPage()
                  d = jp.Div(text="Hello ! Click Me!")
                  d.on("click", my_click)
                  wp.add(d)
                  return wp
  
              return webpage
  
  
          app = LightningApp(Flow())
code: def __init__(self, render_fn: Callable) -> None:
      super().__init__()
  
      if inspect.ismethod(render_fn):
          raise TypeError(
              "The `JustPyFrontend` doesn't support `render_fn` being a method. Please, use a pure function."
          )
  
      self.render_fn = render_fn
      self._process: Optional[Popen] = None
  
file_path: pytorch-lightning/src/lightning/app/frontend/just_py/just_py.py
imports: import inspect
  import os
  import sys
  from subprocess import Popen
  from time import sleep
  from typing import Callable, Optional
  import lightning.app
  from lightning.app.frontend.frontend import Frontend
  from lightning.app.utilities.log import get_logfile
label_desc: Use image node_id 1 to create a new JustPyFrontend object from inherited base classes: Frontend with example: obj = JustPyFrontend(render_fn)