Creating Python Apps with GUIs

To create a Python app with a GUI, use PySide to add widgets and connect their signals (“clicked”, etc.) to slots (Python functions).

Here is the complete code (65 lines) of a simple app with two buttons to add and erase bonds. The app first creates two buttons buttonAddBonds and buttonEraseBonds, and places them in a vertical layout. Then, these two buttons are connected to two Python slots: onAddBonds and onEraseBonds. The slots use the samson package to interact with the active document and the molecules it contains.

Paste this code in SAMSON’s Code Editor, and just click run to start the App !


Comments are closed.