我在下面有一个示例脚本。将弹出警报消息,但用户必须在脚本继续运行之前确认。那么如何在Python中弹出警报并同时保持进程运行?
JSONObject object = task.execute(searchString, search).get();
...
final int numberOfItemsInResp = object.length();
答案 0 :(得分:0)
这会在一个单独的线程中启动警报,这样它就不会阻塞主线程。
import random
import time
import threading
def alert():
ctypes.windll.user32.MessageBoxW(0, "The number generated is less than 10", "ALERT", 1)
for _ in range(20):
a = random.randint(1, 100)
print (a)
if a <= 10:
thread = threading.Thread(target=alert)
thread.start()
time.sleep(.5)