Notifications
Clear all
[Closed] Updating a progressbar from inside a loop
Dec 10, 2009 7:14 pm
Hey guys!
I’m working on a small tool with some heavy ray casting and I want to add a progressbar to the UI so the user can see whether he should wait or go grab another coffee.
The issue is that setting the value inside the raycasting loop of the function will not update the displayed progress until the loop is over.
How can I update the progressbar at timed intervals or per loop interation?
Cheers!
-Sascha
2 Replies
Dec 10, 2009 7:14 pm
2 possible conditions…
1 >> if the for loop is incrementin using an integer
rollout eh "eh?" width:162 height:103
(
progressBar progress_y0 "" pos:[7,31] width:148 height:8 color:(color 0 255 0)
button btn1 "progress Y0" pos:[16,56] width:128 height:24
on btn1 pressed do
(
if progress_y0.Value != 0 then (progress_y0.Value = 0) else (
for i = 1 to 300 do
(
progress_y0.value = 100 * i/300 --Simple old shool formula for calculating precentahe y0.
)
)
)
)
createdialog eh
2 >> If the for loop is incrementing using some objects in the scene
rollout eh "eh?" width:162 height:103
(
progressBar progress_y0 "" pos:[7,31] width:148 height:8 color:(color 0 255 0)
button btn1 "progress Y0" pos:[16,56] width:128 height:24
global i = 0
on btn1 pressed do
(
for geo in selection as array do
(
if i != selection.count then
(
i += 1
if progress_y0.value != 0 then (progress_y0.value = 0) else (
progress_y0.Value = 100 * i/selection.count
)
)
)
i = 0
)
)
createdialog eh
–sorry for my bad english -lol.