Browse Source

fix: doc demo of `put_loading()` error

wangweimin 3 years ago
parent
commit
8a957b4c36
2 changed files with 3 additions and 1 deletions
  1. 1 0
      demos/doc_demo.py
  2. 2 1
      pywebio/output.py

+ 1 - 0
demos/doc_demo.py

@@ -3,6 +3,7 @@ Run the example code in the documentation online
 """
 from functools import partial
 from os import path, listdir
+import time
 
 from pywebio import start_server
 from pywebio.output import *

+ 2 - 1
pywebio/output.py

@@ -904,7 +904,8 @@ def put_loading(shape='border', color='dark', scope=Scope.Current, position=Outp
                 put_loading(shape=shape, color=color)
 
         ## ----
-        # Use as context manager
+        import time  # ..demo-only
+        # Use as context manager, the loading prompt will disappear automatically when the context block exits.
         with put_loading():
             time.sleep(3)  # Some time-consuming operations
             put_text("The answer of the universe is 42")