検索 - User list
Full Version: Python command to refresh Context Options Editor?
Root » Solaris and Karma » Python command to refresh Context Options Editor?
Tim Crowson
Is there a method available to refresh the Context Options Editor UI via Python? I am automating the management of certain Context Options, which is working fine, but to see my automated changes in the Editor I have to click the Refresh button. Is there a method I can call that does the same thing?
Hamilton Meathouse
You could map it to a hotkey or run as a pre-flight script.
Drag the button into the python shell window. That will give you the parm name. Add “.pressButton()” to the end of that parm and hit enter.

If that works, then you could make a python shelf script and assign that script a hotkey. It's not automated in the sense you are looking for, but may be of use during day-to-day work.
Tim Crowson
Unfortunately the Context Options Panel's buttons don't seem to be parms per se. Even the docs for the panel say that options added via hou.setContextOption() would require the user to click on the refresh button.

But we really need the option to force this refresh programmatically without clicking (i.e. if a certain event is triggered, fire the update command). Manually managing context options isn't always desirable or even practical, especially if the content we are managing is complex. We have easy methods for managing the options themselves, we just need a method to update the options in the UI. If the method that is being called by the refresh button can be exposed to us, that would do the trick.
mtucker
The context options UI is a python panel, defined in $HH/python2.7libs/contextoptions.py. It defines an OptionsEditor class with a reload() method (which is what the Refresh button calls).

The problem is that right now, the Context Options menu item creates a new panel every time that menu item is chosen. So there is no way to access a global OptionsEditor object on which to call the reload method. I'd say this is a bug, and I'll report it as such. But for now, you could probably customize the MainMenuCommon.xml menu file that defines the top level menu, and change the Context Options menu item behavior to put a single shared OptionsEditor object in the Houdini session module, then you can call reload on that OptionsEditor whenever you change an option value.
Tim Crowson
Thanks for the insight. Hope this panel can get some love as development progresses, but it's good to know what my options are.
protean
Hi!

Was there any update to this functionality? I'm running into the same issue where context options can be made, deleted and imported but still needs user input to refresh the UI. I'm gonna go and break stuff by editing XMLs now.

Cheers,

j
gg3d
For me, this workaround is working:

from PySide2 import QtWidgets
editors = [w for w in QtWidgets.QApplication.instance().allWidgets() if str(type(w))=="<class 'contextoptions.OptionsEditor'>"]
for editor in editors:
  editor.reload()
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB