Digital I/O Modul Signals

Hello, i wrote a streamlit application for taking pictures from a camera. At the moment the camera triggering is done manually with a button.
Is it possible to use a I/O module with streamlit? I cant run my code in a while True loop, because i need interaction with widgets in the sidebar and thats not possible if my code is running in the loop.