Hi. I have a problem, similar to this question (The provided answer does not work for me). I have a python macro in a Calc document that runs a long calculation and I would like to update cell contents during the macro’s execution. Here is a simple example:
import time
def myfunction(*args):
desktop = XSCRIPTCONTEXT.getDesktop()
model = desktop.getCurrentComponent()
sheet = model.CurrentController.ActiveSheet
cell = sheet.getCellByPosition(0, 0)
cell.setString("In progress...")
# Some long calculation
time.sleep(5)
cell = sheet.getCellByPosition(1, 0)
cell.setString("done.")
return None
My problem is that “In progress” is not displayed until the function returns, when “In progress…” and “done.” appear at once. Is there a way to update cell contents during the execution of the macro?
I have attached a document with the macro included.