瀏覽代碼

fix: doc demo of `put_loading()` error

wangweimin 3 年之前
父節點
當前提交
8a957b4c36
共有 2 個文件被更改,包括 3 次插入1 次删除
  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")