How to prevent Outliner refresh during script execution?

Hi everyone, Is there any command or method to prevent the Maya Outliner from refreshing?
I found that using cmds.refresh(suspend=True) only locks the 3D viewport updates.

In my UI, I’ve designed a progress bar that calculates progress based on the number of tasks,
and during the process I call QtWidgets.QApplication.processEvents() to refresh the progress bar UI.

However, this also causes Maya’s viewport and UI to update frequently.
While cmds.refresh(suspend=True) works well to freeze the 3D viewport,
it doesn’t seem to stop the Outliner from constantly refreshing

This is how i disable/enable everything for one of my tools, it works for me as i recall made things faster:

	def disable_all_panControl(self, enabled=True ):
		""" 
		Disable or Enable all modelPanel controls.
		"""
		all_mp= cmds.getPanel(allPanels= True) # disable all panels, the hypershade ball panel was problematic

		for p in all_mp:
			if p != "scriptEditorPanel1": # skip scripteditor in case of errors.
				try:
					cmds.control(p, edit=True, visible= enabled, en= enabled)
				except:continue
1 Like

One possible, more targeted, option is to lock/unlock the selection connection to the main Outliner.

outlinerEditor -edit -lockMainConnection outlinerPanel1;
// do stuff here...
outlinerEditor -edit -unlockMainConnection outlinerPanel1;
1 Like