Jump to content

hou.InteruptableOperation outside of a with statement?


glassman3d

Recommended Posts

Hi there

I am trying to create a generic progress bar so have been looking at hou.InteruptableOperation

My conundrum is that due to in-house generic pipeline tools that implement this for all packages (including maya and softimage), I need to separate out the progress bar into 3 stages:

Creation

Update

Exit

The docs state not to call this class unless I am within a ‘with’ statement. This makes the separation of these stages very difficult

I am attempting to call the __enter__ and __exit__ methods directly but am not having much luck

Could someone give me a pointer about how to achieve this?

Many thanks!

Link to comment
Share on other sites

answer from SESI:

Hello Sam,

It sounds like you should set the long operation name/message in hou.InterruptableOperation in order to update the progress bar dialog with message updates.

For example:

# Create an interruptable operation.

operation = hou.InterruptableOperation("Doing Work", long_operation_name="Starting Tasks", open_interrupt_dialog=True)

# Start the operation. This will pop-up the progress bar dialog after a second or two.

operation.__enter__()

# Execute tasks. Periodically update the progress percentage and message in the progress bar.

num_tasks = 10

for i in range(num_tasks):

# Do task work here. For this example, just sleep for a second.

time.sleep(1)

percent = float(i) / float(num_tasks)

operation.updateLongProgress(percent, "Finished task %i" % (i + 1))

# Stop the operation. This closes the progress bar dialog.

operation.__exit__(None, None, None)

I hope this helps.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...