How to enable screen refreshing during a calc (python) macro?

A lot of people want to stop their screen from refreshing while their macro is running but I want the opposite. I’d like to update my spreadsheet periodically to let the user know the script is running and calc has not locked up. My macro can take a minute or two to run, so after 10 seconds or so the screen dims and it looks like an app that’s frozen.

Looking into this, I’ve seen people refer to ThisComponent.lockControllers and ThisComponent.unLockControllers, but I haven’t been able to get those functions to work. From my limited understand of the API it seems like from com.sun.star.lang import XComponent should get me there but I’m getting an AttributeError when I try to call either function.

And I’m not 100% convinced that I’m barking up the right tree - it sounds like (from all the people who are trying to turn lock it to prevent screen refreshes) like the controller should be unlocked by default.

So any tips on visually updating the spreadsheet while a macro is running are appreciated. Ideally in python, since I haven’t been able to convert the basic examples successfully.

How about to use Status Indicator? This is the standard way to notify the user that the process is still ongoing (just oFrame.createStatusIndicator(), .start(status_text, maxValue) and .setValue(nextStep) )

Just tried that - it ran with no errors, but no progress bar (or anything else) appeared. Edit: Actually I’m sure it did appear - I was expecting a pop-up progress box so I missed the subtle change in the bottom left status line. This is the same method you suggest in your answer below - I don’t want people thinking these are two different methods.

OK, please try code from this file - demoStatusIndicator.ods

Much better - I get the “please wait” indicator and I get “some” of the progress bar. In my code there are 17 iterations, calling the same sIndicator.setValue(index) after each iteration. Usually only a few of those 17 show on the progress bar. So it’s often 0%, 6%, 12%, 18%, then nothing until the code finishes. One time in about 10 tries the progress bar seemed to show all the steps. It’s as if my code’s running at a much higher priority. Is there a python equivalent to “DoEvents”?

Interesting - the above comment was running under Windows 10 - progress bar updates seem intermittent.

Under linux (Ubuntu 16.04), the progress bar consistently updates for all 17 segments, although the screen still dims, indicating the process is not responding (I’d prefer it not do that).

I’ll tell you more: run the same macro on the same operating system at LibreOffice 4.4.5.2, 5.0.4.2, 5.1.1.3 and OpenOffice 4.1.2 - is different. I have trained myself to treat this as a natural disaster - storm rains or a flock of mosquitoes: we cannot change it - so will endure

Got it. :slight_smile: And thanks!