I'm not sure why self wouldn't be defined without seeing the whole code but my guess would be some indentation is wrong somewhere. I took a stab at your function and this appears to work in my rv. I had to make some changes though as I didn't see any python bindings for those looklut functions (I could be wrong, the rv/python/mu browser isn't the best) As for updating the py file. While I'm IP, I just edit the python script in the Python/ folder until it's working and then I update the .rvpkg file with the fixed version because if you toggle off the plugin in the prefs and back on, it'll probably unzip the rvpkg file back over your fixed .py file. Good luck and hope this helps!
from rv.rvtypes import * from rv.commands import * from rv.extra_commands import * from rv import rvui from pymu import MuSymbol class PyMyStuffMode(MinorMode): def __init__(self): MinorMode.__init__(self) self.tl = MuSymbol("rvui.toggleLookLUT") self.init( "py-mystuff-mode", [("key-down--d", self.lookLut, "")],None,[ ("Color", [ ("Look Lut", self.lookLut, "d", None)])] ) def lookLut(self,event): self.tl() activestate = rv.commands.getIntProperty("#RVLookLUT.lut.active") print activestate def createMode(): return PyMyStuffMode() ----- Original Message ----- | From: "Bruno-Pierre Jobin" <bpjo...@gmail.com> | To: "Nuke Python discussion" <nuke-python@support.thefoundry.co.uk> | Sent: Monday, March 27, 2017 2:56:22 PM | Subject: Re: [Nuke-python] Add RV shortcut | Thanks to both of you. | @Magno, your workaround seems to work only on functions that have a | "nil" shortcut. I tried change "L" from Color/Cineon to Color/Alexa | and the hotkey still triggered Cineon. | @Nathan, thanks for helping me understand what were all these "None" | in the doc's example. I'm still getting an error though. Not sure | File "/home/bpjobin/.rv/Python/mystuff.py", line 9, in PyMyStuffMode | self.init( | NameError: name 'self' is not defined | Here's line 9 : | class PyMyStuffMode(MinorMode): | def __init__(self): | MinorMode.__init__(self) | ---> self.init("py-mystuff-mode", | [('key-down--d', self.lookLut, 'Custom LookLUT key override')], | None, | [('Color', [('Look LUT', self.lookLut, 'd', None)])] | ) | Another question, once the package as been zipped and added to RV's | packages, do I need to recompile it every time or, as Nuke works, | simply making changes to my .py file when restarting RV will do it? | On Mon, Mar 27, 2017 at 12:54 PM, Nathan Rusch < | nathan_ru...@hotmail.com > wrote: | | Hi Bruno, | | | RV's customization system is needlessly complex, particularly when | | it | | comes to overriding or unbinding existing hotkeys. In your case, it | | looks like you just need to make sure you're passing the right | | arguments to `MinorMode.init`. The required arguments are `name`, | | `globalBindings`, and `overrideBindings`, in that order, with | | optional menu commands after that. | | | The `globalBindings` and `overrideBindings` args are lists of | | three-tuples in the form ('eventName', eventHandler, 'docString'), | | and keyboard event names take the form 'key-down--<KEY>'. To be | | thorough, you probably want to specify the hotkey in both the event | | binding and the menu item. | | | I think this should be what you need: | | | self.init( | | | 'py-mystuff-mode', | | | [('key-down--d', self.lookLut, 'Custom LookLUT key override')], | | | None, | | | [('Color', [('Look LUT', self.lookLut, 'd', None)])] | | | ) | | | Hopefully I didn't mismatch any parentheses or otherwise screw up | | the | | syntax... my email client doesn't do syntax highlighting. ;) | | | -Nathan | | | On 3/27/2017 7:51 AM, Bruno-Pierre Jobin wrote: | | | | Hey, | | | | | | Can anyone tell me what I doing wrong here? I'm trying to assign | | | the | | | "D" key to an RV's Color/LookLUT command. I'm putting this script | | | in | | | my /home/.rv/mystuff directory as explained in the doc. Then I | | | zip | | | it using the PACKAGE and this py file. Does anything seem odd in | | | this script? I just started playing with RV modules last week. | | | | | | Thank you! | | | | | | from rv.rvtypes import * from rv.commands import * from | | | rv.extra_commands import * class PyMyStuffMode (MinorMode): def | | | __init__ ( self ): | | | | | | MinorMode. __init__ ( self ) | | | | | | self.init( "py-mystuff-mode" , [ | | | | | | ( "Color" , [( "Look LUT" , self.lookLut , 'd' )] | | | | | | ) | | | | | | ] , None , [( "Color" , [( "Look LUT" , self.lookLut , "" , None | | | )]) | | | ] ) def lookLut ( self , event ): | | | | | | toggleLookLUT() if isLookLUTActiveState: | | | | | | displayFeedback( "Look LUT ON" ) print | | | isLookLUTActiveState.value() | | | else : | | | | | | displayFeedback( "Look LUT OFF" ) print | | | isLookLUTActiveState.value() | | | def createMode (): return PyMyStuffMode() | | | | | | -- | | | | | | Bruno-Pierre Jobin | | | | | | www.bpjobin.com | | | | | | _______________________________________________ | | | | | | Nuke-python mailing list Nuke-python@support.thefoundry.co.uk , | | | http://forums.thefoundry.co.uk/ | | | http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python | | | | | _______________________________________________ | | | Nuke-python mailing list | | | Nuke-python@support.thefoundry.co.uk , | | http://forums.thefoundry.co.uk/ | | | http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python | | -- | Bruno-Pierre Jobin | www.bpjobin.com | _______________________________________________ | Nuke-python mailing list | Nuke-python@support.thefoundry.co.uk, | https://urldefense.proofpoint.com/v2/url?u=http-3A__forums.thefoundry.co.uk_&d=DwICAg&c=hHkK43hKb5uKUGaYMJ-p252cFdfVBHtyegDvswk59fU&r=hdh6ldFziktt1N0wAi7bK3Mjov-6LjULd6ZgRd44U6s&m=baR340Snu4RBkv7djIT3nPkdAHmClRoKv3ggcqec6pY&s=nvGMWjhxksBF_MRzf5m1eUrOhBnYLufMZEkwlwU_X60&e= | https://urldefense.proofpoint.com/v2/url?u=http-3A__support.thefoundry.co.uk_cgi-2Dbin_mailman_listinfo_nuke-2Dpython&d=DwICAg&c=hHkK43hKb5uKUGaYMJ-p252cFdfVBHtyegDvswk59fU&r=hdh6ldFziktt1N0wAi7bK3Mjov-6LjULd6ZgRd44U6s&m=baR340Snu4RBkv7djIT3nPkdAHmClRoKv3ggcqec6pY&s=7YQknVkSMwVe6_Xx7IWBp7rJWlOFdl5YyLRHbkrQ8IQ&e=
_______________________________________________ Nuke-python mailing list Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python