[Maya 2014] ProgressBar can't be canceled?

I am using maya’s native progressBar UI widget and I am having trouble with cancelling the progress. I can’t use the progressWindow, since I need a custom layout and need to support sub-progress bars.

I am having trouble capturing the isCanceled event… isCanceled is never returning True… I assumed it would capture the ESC key, but that does not work… according to the docs, isInterruptable is only valid for the main progressBar and progressWindows, but not for progressBars added to custom UIs…


import time
import maya.cmds as cmds
window = cmds.window()
cmds.columnLayout()
progressControl = cmds.progressBar(maxValue=10, width=300)
cmds.showWindow( window )

for i in range(10):
    if cmds.progressBar(progressControl, q=True, ic=True):
        break
    cmds.progressBar(progressControl, e=True, step=1)
    time.sleep(1)

i found a work around to this issue but it feels kinda hacky.

I added a button to the window that sets a class attribute self.cancelled to TRUE when clicked, and then I added QtGui.qApp.processEvents() to my loop. Each iteration, I ask the class instance for it’s cancelled property and abort.

from the docs it looks like the progressbar when used in the main window is cancellable. What youre doing sounds like the right direction. You need to handle the cancel state yourself.

isInterruptable(ii)
Only valid for the main progress bar