Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Experimented with implementing a progress bar for longer tasks in Modo, didn't quite get it to work due to focus being stolen from rendering.
import lx
from time import sleep
SECONDS = 15
# Initialize the monitor object, ie progress bar.
monitor = lx.Monitor()
monitor.init(SECONDS)
# Mimic a long operation that users might want to stop.
for i in range(SECONDS):
sleep(1)
try:
# If user aborts the monitor, a runtimeerror will be raised.
monitor.step(1)
except RuntimeError as error:
lx.out("Operation cancelled by the user.")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment