MenuItem in RV 2021.0.0 and Python3?


We have some custom RV packages. The menu shortcuts stopped working with this update.

The only python menu syntaxe I’ve found is:

MenuItem(string label,
(void;Event) actionHook,
string key,
(int;) stateHook);
from RV 3.12 Documentation

Any string like “ATL+I” are not accepted any more. If I set it to None, my package works but no shortcuts of course.

It worked until RV 7.9.

Is there a new MenuItem structure? and even better an up-to-date documentation?


Hi Kevin,

In Python 3, you may have to convert your text strings in bytes so that RV can work with it. Can you try installing and using the python six module to ensure that the shortkey is in binary?

Something like that:

(“label”, self.action, six.ensure_binary(“Alt+I”), None)

That way, your script will be Python 2-3 compatible.



Thank you Iseal.

For completeness:
Python 3 enforces the distinction between byte strings and text strings far more rigorously than Python 2 does; binary data cannot be automatically coerced to or from text data. six provides several functions to assist in classifying string data in all Python versions.

six. ensure_binary ( s , encoding=‘utf-8’ , errors=‘strict’ )

Coerce s to binary_type . encoding , errors are the same as str.encode()

1 Like