Developing scripts#
Using SAMSON AI#
SAMSON AI is the intelligent assistant for SAMSON. This assistant is designed to help you navigate SAMSON’s functionality and understand its commands, menus, editors, apps, and more. It can explain the platform’s functionality, all while providing links to relevant documentation for further understanding, and can also directly execute SAMSON commands.
You can open the SAMSON AI via Interface menu > Windows > Assistant or via the Ctrl+0 shortcut on Windows and Linux or Cmd+0 on Mac.
You can use SAMSON AI to help you script with Python. For that, use /script command in the Assitant. Example: /script select all atoms and translate them in the z direction by 1 angstrom.
You can execute the suggested scripts directly from the Assistant.
See more in User guide - SAMSON AI.
Using Code Editor#
The Code editor in SAMSON provides the possibility to open and modify Python scripts and other text files. It also provides the possibility to run Python files, whether embedded into documents or not.
To open the Code editor, click on Interface menu > Code editor or press Ctrl+9 on Windows and Linux or Cmd+9 on Mac.
Embedding Python Scripts#
You can embed Python scripts directly into a SAMSON document making the document self-contained, so you can transfer documents between computers and share documents, and store whole pipelines in the document.
Installing Python packages#
To install a Python package, go to Python Console > Edit > Manage packages and provide the package name and click Install.
The Python console uses pip
internally, so you can specify the package version, if necessary, in the same way as when using pip
.
GUI#
SAMSON Python API provides a set of functions that you can use to interact with the user via pop-up dialogs, e.g.:, get filenames, paths, strings, numbers, ranges, colors and color palettes, choose an item from a list, etc. Thus, you can use the existing functionality without the need to create your own dialogs. Please see SAMSON
for the corresponding functions.
To develop more complex dialogs and apps you will need to use Qt. SAMSON uses Qt6 for GUI and the integrated Python environment installs PySide6 (Qt6 bindings for Python) for you. So, to create GUI, please use PySide6 or the qtpy wrapper which will automatically select the available Qt Python package.
To learn more how to create GUIs with Qt, please refer to the PySide6 documentation.
See also
Examples: Apps and GUIs