您没有提供足够的代码示例来帮助您。首先,您的 callback() 函数包含一个 break 语句,即使该函数中实际上没有循环。
无论如何,我编写了以下示例进行检查,实际上它仅在达到 100 时打印一次“完成上传”。
import maya.cmds as cmds
cmds.progressBar('progressBar') # initialise the progress bar
def callback():
# Begin loop from 0 to 100 - remember range(n) returns numbers from 0 (inclusive) to n (exclusive)
for i in range(101):
cmds.progressBar('progressBar', edit=True, step=1) # increase step by 1
if (cmds.progressBar('progressBar',q=True, progress=True)==100):
print "Finished Uploading."
break
# Theoretically, breaking is simply here so that you stop wasting iterations in some cases,
# but it's not necessary for the printout, since we have only specified that the print will
# happen when the progress value is equal to exactly 100.
# Finally, if there is NO loop (like the code you pasted originally), then you shouldn't have
# a break.
callback()
您的问题的一个可能原因是您的进度条进度超过 100 步,并且进度条的最大值为 100。在这种情况下,随着您不断增加步数,该值将保持在 100(即最大值),因此每次查询它是否等于 100 时,它都会返回 True。
不幸的是,如果没有您提供的更具体的信息,我无法回答任何更具体的问题。