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.

You might want to wrap that around to handle cases where activeViewer
resolves to None, or get the information you need from somewhere else.

Hope that helps.



On Thu, Nov 7, 2013 at 8:52 AM, Richard Bobo <richb...@mac.com> 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 <richb...@mac.com> 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:  richb...@mac.com                      
> Mobile:  248.840.2665
> Web:  http://richbobo.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

Reply via email to