Skip to content

Instantly share code, notes, and snippets.

@rondreas
Created March 2, 2021 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondreas/426faabe28197bd66ac5f63e6e91b969 to your computer and use it in GitHub Desktop.
Save rondreas/426faabe28197bd66ac5f63e6e91b969 to your computer and use it in GitHub Desktop.
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