Python setup

Requires the following resources:

  • An internet connection to download and install Simian GUI from our PyPi server (or an offline alternative).

Setup steps:

  1. Create and activate a Python environment.

    Note: Use Python 3.8 - 3.12.

  2. Install the packages using pip:

    pip install --extra-index-url https://pypiserver.monkeyproofsolutions.nl/simple/ simian-gui simian-local simian-examples
    

    Note that for installation on a deployment server the simian-local and simian-examples packages are not required.

    1. The simian-local package installs pywebview as a dependency. To verify it is installed correctly on your system, run the following python commands. A window, displaying the PyWebview web page, should open.

      import webview
      webview.create_window('Hello world', 'https://pywebview.flowrl.com/')
      webview.start()
      
    2. If you want to use Redis cache (for deployed mode) it can be specified as optional dependency of the simian-gui:

      pip install simian-gui[redis]
      

Testing your setup

You can test your environment setup by running the following commands in your Python environment:

import simian.gui
form = simian.gui.Form()

If you get a Form object, your environment is setup correctly. If pywebview is installed correctly in your Python environment, you should be able to start the BallThrower example locally by running the following commands:

import simian.local
simian.local.Uiformio("simian.examples.ballthrower", window_title="Ball Thrower")

If you get an error, you can check this against these error messages and solutions:

  • ModuleNotFoundError: No module named 'simian' Simian GUI was not found on the Python path. Ensure that the simian-gui and simian-local packages are installed.

  • ModuleNotFoundError: No module named 'simian.examples.ballthrower' The simian-examples package was not found on the Python path. Ensure that the simian-examples package is installed.

  • ModuleNotFoundError: No module named xxx Ensure that all dependencies are installed in your Python environment.

Simian GUI contents

A full Simian GUI installation in your Python environment installs the following folders and files in the site-packages folder:

From simian-builder:

  • simian
    • css CSS for the builder.
    • templates Templates for creating apps and composed components.
    • builder.json Builder form definition.
    • builder.py The Builder module.
    • version.txt Version information.

From simian-examples:

  • simian
    • examples
      • all_components.py Web app with all components that can be used in Simian.
      • ballthrower.py Web app with the BallThrower application. It contains the gui_init and gui_event functions that define the user interface of the application.
      • ballthrower_engine.py Module with a class that implements the ball throwing model.
      • plot_types.py Web app showing some of the Plotly figures that can be used in Simian.
      • workshop_example.py Web app showing a DataTable and Plotly figure in use.
      • wrapped_thrower.py Web app with the BallThrower and a engine that is wrapped with Simian Wrapper.
    • version.txt Version information.

From simian-gui:

  • simian
    • gui Folder containing Simian GUI code.
    • config.json File containing the version number of the front-end.
    • entrypoint.py Utility for handling callbacks.
    • version.txt Version information.

From simian-local:

  • simian
    • html Folder containing the front-end build for PyWebview.
    • eventh_handler.py Utility for communication with tht PyWebview window.
    • local.py The Simian Local module.
    • local.pyi Python stub file containing type hints for the local.py module.
    • version.txt Version information.