Progress dialog not hiding

Progress dialog not hiding

j.han97
Advocate Advocate
367 Views
2 Replies
Message 1 of 3

Progress dialog not hiding

j.han97
Advocate
Advocate

Hi all,

 

I have encountered some problems while using the progress dialog in my add-in. The progress dialog is not hidden when the delay is longer than the progress itself.

 

For example, I have tested this in a simple block of code below:

# This event handler is called when the user clicks the OK button in the command dialog or 
# is immediately called after the created event not command inputs were created for the dialog.
def command_execute(args: adsk.core.CommandEventArgs):
    # General logging for debug.
    futil.log(f'{CMD_NAME} Command Execute Event')

    # TODO ******************************** Your code here ********************************
    func1()
    

def func1():
    global progDiag
    
    if not progDiag:
        progDiag = ui.createProgressDialog()
        progDiag.cancelButtonText = 'Show'
        
    progDiag.show(
        'Test',
        'f1: Running: %p%',
        0, 
        5,
        8
    )
    
    for i in range(5):
        time.sleep(1)
        progDiag.progressValue += 1
        
    
    progDiag.hide()

 

The progress takes 5 seconds but I set the delay to be 8 seconds. After running this in an add-in, the progress dialog is not hidden.

 

jhan97_0-1647224913821.png

 

Does anyone have an idea on how to avoid this issue?

 

Thanks a lot!

0 Likes
368 Views
2 Replies
Replies (2)
Message 2 of 3

tykapl.breuil
Advocate
Advocate

I confirm that I am able to reproduce the issue. I don't see any way to solve this through the progressDialog object as there is no way to delete it or change the delay. The only thing I see that might work is to create a separate thread to automatically hide the progressDialog after the delay has passed but that is really ugly...

 

This is quite a bad bug as it makes the delay value absolutely useless, according to the documentation :

 

"Specifies the time interval in seconds to delay displaying the Progress Dialog. This provides a way to hide the progress dialog before it actually gets displayed, which is useful for cases where the progress of the operation being tracked completes quickly and there is no need to indicate progress to the user.

This is an optional argument whose default value is 0."

 

EDIT: I just realised that if a progress dialog is used in a script and the script is terminated before the delay procs, the progress dialog gets cleaned up and isn't shown. This probably won't help for your use case but still interesting to note.

Message 3 of 3

j.han97
Advocate
Advocate

Thanks @tykapl.breuil for your reply.

 

I got confused by the documentation too. It does not provide much information too, therefore I am not sure if I am using the progress dialog in the right way.

0 Likes