Update python Tool UI during loop function

Update python Tool UI during loop function

damian.pajda
Advocate Advocate
1,821 Views
1 Reply
Message 1 of 2

Update python Tool UI during loop function

damian.pajda
Advocate
Advocate

In a tool written in python (using PySide and FBWidgetHolder), I have a button, that runs a quite long function.

During this function I would like to change Label of this button to i.e. "Working...", but this label updates only after function do its job.

Looks like function have a priority before UI.

Does anyone know how to force Tool UI or Mobu UI to update?

Similar issue would be if I would want to use pyside progress bar or print some kind of log in the tool window.

 

0 Likes
Accepted solutions (1)
1,822 Views
1 Reply
Reply (1)
Message 2 of 2

damian.pajda
Advocate
Advocate
Accepted solution

Ok, I found solution. 

Function QApplication.processEvents() forces UI to update.

I didn't test it to much but looks as it works well.

i.e.

 

btn_export.setText("Working...")
QApplication.processEvents()

 

0 Likes