Created
March 2, 2021 08:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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