Python command to refresh Context Options Editor?

   4257   6   1
User Avatar
Member
250 posts
Joined: 10月 2014
オフライン
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?
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
209 posts
Joined: 11月 2013
オフライン
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.
User Avatar
Member
250 posts
Joined: 10月 2014
オフライン
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.
Edited by Tim Crowson - 2020年5月16日 18:05:33
- Tim Crowson
Technical/CG Supervisor
User Avatar
スタッフ
4558 posts
Joined: 7月 2005
オンライン
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.
User Avatar
Member
250 posts
Joined: 10月 2014
オフライン
Thanks for the insight. Hope this panel can get some love as development progresses, but it's good to know what my options are.
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
75 posts
Joined: 7月 2006
オフライン
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
john @ goodbyekansas
User Avatar
Member
1 posts
Joined: 9月 2019
オフライン
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()
Edited by gg3d - 2021年4月12日 03:31:38
  • Quick Links