Skip to content

Commit 8457002

Browse files
committed
Add usage example for FSlowTask
1 parent 38c9399 commit 8457002

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

examples/slow_task.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from unreal_engine import FSlowTask
2+
import time
3+
4+
# Create an FSlowTask object, defining the amount of work that
5+
# will be done, and the initial message.
6+
t = FSlowTask(10, "Doing Something")
7+
t.initialize()
8+
9+
# Make the dialog, and include a Cancel button (default is not to
10+
# allow a cancel button).
11+
t.make_dialog(True)
12+
13+
time.sleep(1)
14+
15+
for i in range(10) :
16+
# Update the progress bar. Note that the first argument is the
17+
# amount of work to be done this frame, not the overall work
18+
# done so far.
19+
t.enter_progress_frame(1, "Progress Position : {}".format(i))
20+
time.sleep(0.2)
21+
22+
# If there was a cancel button included, we can check if it was
23+
# pressed.
24+
if t.received_user_cancel():
25+
print("Cancelled")
26+
break
27+
28+
t.destroy()

0 commit comments

Comments
 (0)