Showing progress of your script running

I have a script that runs for a while, several minutes. Is there any way to display the progress of the script? Like use the progress bar that shows baking progress?


Thanks!

Short answer: no, not like that.

See links and references here:
http://blender.stackexchange.com/questions/23346/access-progress-bar-via-python

Ahh, thanks, this sucks, really :frowning:
I don’t understand why they won’t give access to such basic things.
I guess I’ll have to go with the solution of mouse cursor progress, even though it’s mighty ugly.

It’s impossible to implement at the moment. It would mean to re-write a lot of the window and event handling system as far as I understand.

I would sugest to bypass blender’s GUI and use OS api directly to draw progress right in the taskbar. But (I dunno about Unix systems) on Win systems it requires aditional libraries such as win32api, ect. So this wont do if you planning to distribute your script as is

It is sad there is no correct way to do this. The little crappy progress mouse cursor does not work on Windows with long operations, because it just changes to the default busy animation. And it is basically impossible to easily cancel operations. There are hacky ways around this for some things, modal operator with gl calls you can draw over the entire window by resetting the scissor rect and display progress of an external process with a timer, but this hardly makes it easy for tools INSIDE of Blender, where the tool action blocks Blender from doing anything else, such as drawing the progress or accepting input for cancelling an op.

Someone mentioned the reverse done, expensive operator in blender, uses IPC to talk to an external program that does nothing but display a progress bar and cancel button. It sends progress info from somewhere in its loop and also asks for cancel state, if cancel state is true it breaks out of the loop. Still sounds very hacky.

There really needs to be a dedicated fullscreen modal progress operator, something that just grays the entire window, then displays a simple progress bar, optional log (or message output), and a cancel button.

Seeing as how nothing has been done to remedy this for many years, I would guess such a thing is nowhere on anybody’s priority list. Hacks and workarounds are generally required when dealing with a UI design paradigm where the intended uses are very set in stone. This really should be done, because python is so SLOW, especially for IO and direct mesh data manipulation.

Might consider printing to the console:

The GUI freezes anyway and the mouse timer vanishes for me if i switch to other applications.

Py-Buttons: https://www.youtube.com/watch?v=mRiTfLpRlRU

Last time I tried a custom build of Py Buttons, it crashed immediately on interaction with the custom widget under Windows.

To show progress from 1 to 9999 at mouse pointer location…


# User defined Python variables 'still_running' of type bool, and 'percent' in [0. to 100.]

class Progress(bpy.types.Operator):
    bl_idname = "progress"
    bl_options = {'REGISTER', 'INTERNAL'}
    bl_label = "Run with progress"
    bl_description = "Run with progress"
    def modal(self, context, event):
        wm = context.window_manager
        if still_running:
            wm.progress_update(percent)
            return {'PASS_THROUGH'}
        wm.event_timer_remove(self.timer)
        wm.progress_end()
        return {'FINISHED'}
    def execute(self, context):
        wm = context.window_manager
        wm.progress_begin(0., 100.)
        self.timer = wm.event_timer_add(0.01, context.window)
        wm.modal_handler_add(self)
        return{'RUNNING_MODAL'}

yes you could implement a progress bar using the bgl module. Its ideal for custom guis and has been used by many addons already like screencapture keys and pie menus.