I am now successfully restoring the panel with the script, but I only get the hero view in my pulldown menu - even though I am using nuke.views() to initialize the pulldown. If I close the panel and reopen it, I get all of the listed views. Any way to find those views when restoring the panel on the script loading? Or, is it just an order of operation problem that I won’t be able to workaround??
Thanks, Rich On Nov 7, 2013, at 3:11 PM, Richard Bobo <[email protected]> wrote: > > > On Nov 7, 2013, at 2:33 PM, Nathan Rusch <[email protected]> wrote: > >> Viewers don’t remember what view they were set to when the script is saved; >> they will always open to the script’s hero view, so you can just check >> nuke.root()['hero_view'].value() for your initial value. > > Hmm… I see. Thinking about some other approaches… I’m trying to populate > some pulldowns with the list of views, but when the panel and knobs get > created - as the script loads - the views aren’t available! Hmm… maybe I just > won’t be able to register this panel. Maybe it will always have to be created > *after* the script is opened…?? (8^\ > > Rich > >> >> -Nathan >> >> >> From: Richard Bobo >> Sent: Thursday, November 07, 2013 11:24 AM >> To: Nuke Python discussion >> Subject: Re: [Nuke-python] Registered PythonPanel not appearing when knobs >> areassigned initial values... >> >> >> >> On Nov 7, 2013, at 1:56 PM, Ivan Busquets <[email protected]> wrote: >> >>> Hi Rich, >>> >>> Looking at the code above, my guess is that an active Viewer Window can't >>> be resolved by the time your panel is trying to open. >>> >>> "self.current_view = nuke.activeViewer().view()" >>> >>> Will error out if nuke.activeViewer() is None, and therefore the rest of >>> your panel's initialization will never be executed. >> >> Ivan — Thanks for responding. That’s kind of what I figured, too. >> >>> >>> You might want to wrap that around to handle cases where activeViewer >>> resolves to None, or get the information you need from somewhere else. >> >> I’m going see if I can figure out a later point in my script to get the >> current view — hopefully, after it’s available — and set the knob value, if >> that’s even possible… >> >> Thanks, >> Rich >> >>> >>> Hope that helps. >>> >>> >>> >>> On Thu, Nov 7, 2013 at 8:52 AM, Richard Bobo <[email protected]> wrote: >>> I need to amend my email and correct some erroneous information… >>> >>> —— First of all, setting the knob value to a string, like ‘foobar’, *does* >>> work! >>> ...Not sure what I was doing that made the test not work before, but it >>> does now…. ~(8^P >>> >>> —— Secondly, what does *not* work is setting the knob value to the result >>> of a function. What I am actually trying to do is set the knob’s initial >>> value to nuke.activeViewer().view(). The result is a string, but when >>> recalling the Nuke script with a registered panel - the panel does not >>> show. It does not matter if I set the value beforehand, either. I.e., if I >>> do something like this: >>> >>> self.current_view = nuke.activeViewer().view() >>> …then… >>> self.partStartsWith_knob.setValue(self.current_view) >>> >>> —— That will work fine when initially creating the tabbed panel - but fails >>> to show anything when the script is saved and reloaded. >>> >>> —— So, here’s a better test that shows the problem: >>> >>> import nuke >>> import nukescripts >>> class testpanel( nukescripts.PythonPanel ): >>> def __init__(self): >>> # Get the view name and assign it... >>> self.current_view = nuke.activeViewer().view() >>> nukescripts.PythonPanel.__init__(self, 'View Selector', >>> 'com.richbobo.testpanel') >>> self.partStartsWith_knob = nuke.String_Knob('startswith', 'View >>> Name - Starts With :') >>> self.addKnob(self.partStartsWith_knob) >>> # Set the initial view name value to the knob... >>> self.partStartsWith_knob.setValue(self.current_view) >>> >>> —— Sorry for the confusion! >>> >>> Rich >>> >>> >>> On Nov 7, 2013, at 10:58 AM, Richard Bobo <[email protected]> wrote: >>> >>>> OK, here's an interesting problem... Well, it's "interesting" in the sense >>>> that I can't figure out how to solve it!! (8^\ >>>> >>>> ---- When I add a custom PythonPanel to the Pane menu, create it as a tab, >>>> save the Nuke script and recall it - the panel does not appear! >>>> >>>> ---- The thing that is causing it to *not* appear is assigning an initial >>>> value to the knob. If I don't assign an initial value, the panel appears >>>> in the tab, as expected. This happens with more than one type of knob, by >>>> the way. It seems to be a general problem... >>>> >>>> ---- For debugging purposes, I am making a simple PythonPanel and adding a >>>> String_Knob to it. If I comment out the last .setValue line, the tabbed >>>> panel saves and restores with the Nuke script without a problem. If I >>>> assign a default value, it doesn't. >>>> >>>> ---- Here's the test class: >>>> import nuke >>>> import nukescripts >>>> class testpanel( nukescripts.PythonPanel ): >>>> def __init__(self): >>>> nukescripts.PythonPanel.__init__(self, 'View Selector', >>>> 'com.richbobo.testpanel') >>>> self.partStartsWith_knob = nuke.String_Knob('startswith', 'View >>>> Name - Starts With :') >>>> self.addKnob(self.partStartsWith_knob) >>>> self.partStartsWith_knob.setValue('foobar') >>>> >>>> ---- Here's what I have in my menu.py: >>>> import test_panel >>>> def addtestpanel(): >>>> global testpanel >>>> testpanel = test_panel.testpanel() >>>> testpanel.addToPane() >>>> return testpanel >>>> nuke.menu('Pane').addCommand( 'testpanel', addtestpanel ) >>>> nukescripts.registerPanel( 'com.richbobo.testpanel', addtestpanel ) >>>> >>>> --- Note that there are no errors reported when the panel does not appear. >>>> >>>> It seems that assigning initial values to the knobs of a registered panels >>>> somehow interrupts the mechanism that causes the panel to show. How do I >>>> make sure to insert initial values in the knobs - without causing the >>>> registered PythonPanel to not show?!? >>>> >>>> >>>> Thanks for any help, >>>> Rich >>>> >>>> Rich Bobo >>>> Senior VFX Compositor >>>> Email: [email protected] >>>> Mobile: 248.840.2665 >>>> Web: http://richbobo.com >>> >>> >>> >>> _______________________________________________ >>> Nuke-python mailing list >>> [email protected], http://forums.thefoundry.co.uk/ >>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>> >>> >>> _______________________________________________ >>> Nuke-python mailing list >>> [email protected], http://forums.thefoundry.co.uk/ >>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> >> _______________________________________________ >> Nuke-python mailing list >> [email protected], http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> _______________________________________________ >> Nuke-python mailing list >> [email protected], http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > _______________________________________________ > Nuke-python mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
