UI/FBProgress.py

UI/FBProgress.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Topic: FBProgress, FBSleep
7 #
8 
9 from pyfbsdk import FBProgress, FBSleep
10 
11 # Create a FBProgress object and set default values for the caption and text.
12 lFbp = FBProgress()
13 
14 # Call ProgressBegin() before use any other function and property.
15 lFbp.ProgressBegin()
16 
17 # Set the custom task name.
18 lFbp.Caption = "My Task"
19 
20 # Now simulate work being done. Sleep 20 ms at each iteration.
21 for lVal in range(100):
22  # Stop the progress if user request cancellation by pressing and holding "ESC" key
23  if (lFbp.UserRequestCancell()):
24  break;
25 
26  # Change sub description of the task.
27  if (lVal < 50) :
28  lFbp.Text = "Processing First Part ..."
29  else:
30  lFbp.Text = "Processing Second Part ..."
31 
32  # Sleep 20 ms to simulate the task execution time.
33  FBSleep(20)
34  # Update progress percentage.
35  lFbp.Percent = lVal
36 
37 # We must call ProgressDone() to after progress is finished or cancelled.
38 # to reset the progress bar to normal status.
39 lFbp.ProgressDone()
40 
41 # Cleanup.
42 del( lFbp, lVal, FBProgress, FBSleep )
43