Finally got around to doing something about this again:
While it doesn't directly address the removeKnob bug erroneously populating the panels (bug 37959, which is still broken in nuke8), it does a better job of closing and re-opening the panels (bug 14622) to restore the panel to the correct state. Both techniques mentioned earlier fell apart in various tests, so we've just been putting up with it till now. Here's the fix (adapted from an old tip for something completely different by erik winquist):

[code]
import thread

def _showPanel(node):
    nuke.executeInMainThread(node.showControlPanel, ())

def fixRemoveKnobs(node):
    """Place after node.removeKnob code to hide and then re-show panel to fix nuke 7 bug
    that duplicates panels inside panels."""
    node.hideControlPanel()
    thread.start_new_thread(_showPanel, (node,))

[/code]

cheers
JRAB


On 09/20/2013 12:00 AM, John Vanderbeck wrote:
So just a heads up.  I found that if I put in just the slightest delay, then I can avoid the refresh issue. In the code below, a time.sleep() of just 0.01 is enough to keep the bug from happening.

for i in xrange(thisNode.numKnobs() - 1, -1, -1):

    knob = thisNode.knob(i)

    if knob is thisNode.knob("channel_tip"):

        break

    thisNode.removeKnob(knob)

    time.sleep(0.01)

    layers = []

    for channel in thisNode.channels():

        layer = channel.split(".")[0]

        if not layer in layers:

            layers.append(layer)

for layer in layers:

    knob = nuke.Boolean_Knob("channel_" + layer, layer, True)

    knob.setFlag(nuke.STARTLINE)

    nuke.selectedNode().addKnob(knob)



On Thu, Sep 19, 2013 at 9:06 AM, John Vanderbeck <[email protected]> wrote:
So is there any way to work around this? I'm running into it at the moment and this is very bad for the user.


On Tue, Sep 10, 2013 at 8:29 AM, Nathan Rusch <[email protected]> wrote:
Now logged as bug #37959.

-Nathan

On Sep 10, 2013, at 2:32 AM, "John RA Benson" <[email protected]> wrote:

> fantastic idea with the callback - works great!
>
> many thanks
> JRAB
>
> On 09/10/2013 04:27 AM, Ben Dickson wrote:
>> I'm pretty sure I've had this happen on OS X too, but only when the node's properties was a floating window (i.e the Properties Bin was closed).. Will try to extract the code that caused this into a simple test-case
>>
>> As for reopening the panel, that looks like another bug worth reporting.. Here is a workaround, which hides the panel and re-opens it in an updateUI callback:
>>
>> thisNode = nuke.thisNode()
>> k = nuke.Text_Knob('foo', 'foo')
>> thisNode.addKnob(k)
>> thisNode.removeKnob(k)
>>
>> n.hideControlPanel()
>> def showPanel():
>>    n.showControlPanel()
>>    nuke.callbacks.removeUpdateUI(showPanel)
>>
>> nuke.callbacks.addUpdateUI(showPanel)
>>
>>
>> On 07/09/13 04:14, John RA Benson wrote:
>>> thanks!
>>>
>>> seems to be a linux thing. I just tried my test node on osx and it works fine.
>>>
>>> calling node.showControlPanel() from within the node is something different, but if it worked to re-open the panel, at least I'd have a workaround. It does the same in osx and linux - nothing.
>>>
>>> thoughts?
>>> JRAB
>>>
>>>
>>> On Sep 6, 2013, at 7:28 PM, Nathan Rusch<[email protected]>  wrote:
>>>
>>>> Ha. I actually just reported this issue the other day. From what I can tell, it has to do with knobs being reorganized or reordered without giving Nuke a chance to redraw their widgets. As you say, it's pretty much harmless, as all the widgets are still connected to the same back-end knob, but annoying nonetheless.
>>>>
>>>> I'll follow up on here when I have a bug ID.
>>>>
>>>> -Nathan
>>>>
>>>>
>>>> -----Original Message----- From: John RA Benson
>>>> Sent: Friday, September 06, 2013 10:15 AM
>>>> To: Nuke Python discussion
>>>> Subject: [Nuke-python] multiple panels inside a panel problem
>>>>
>>>> Does anyone have a fix for this problem:
>>>>
>>>> set cut_paste_input [stack 0]
>>>> version 7.0 v8
>>>> push $cut_paste_input
>>>> NoOp {
>>>> name NoOp25
>>>> selected true
>>>> xpos -497
>>>> ypos -19511
>>>> addUserKnob {20 tests}
>>>> addUserKnob {22 reload T "thisNode = nuke.thisNode()\nk =
>>>> nuke.Text_Knob('foo',
>>>> 'foo')\nthisNode.addKnob(k)\nthisNode.removeKnob(k)\n" +STARTLINE}
>>>> addUserKnob {22 reloadCloseAndReopen l "reload, Close and Reopen" T
>>>> "thisNode = nuke.thisNode()\nk = nuke.Text_Knob('foo',
>>>> 'foo')\nthisNode.addKnob(k)\nthisNode.removeKnob(k)\n\nthisNode.hideControlPanel()\nthisNode.showControlPanel()"
>>>> +STARTLINE}
>>>> }
>>>>
>>>> Press the 'reload' button in the noop. I'm just adding a knob, and then
>>>> removing it.
>>>> Basically, if you have a knob that you want to remove and do so, the
>>>> properties panel adds to itself. Each time you run it, it stacks up.
>>>> Doesn't appear to be a problem, but it's really annoying, since you have
>>>> to close the panel and re-open it to normalize it again.
>>>>
>>>> Speaking of opening and closing, is it normal to not be able to open the
>>>> panel with node.showControlPanel() from within a script called by the
>>>> node? Do I need to do some context thing to get it to open?
>>>>
>>>> thanks
>>>> JRAB
>>>> _______________________________________________
>>>> 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



--
- John Vanderbeck
- Prime Focus World, Vancouver
- 2D Pipeline TD




--
- John Vanderbeck
- Prime Focus World, Vancouver
- 2D Pipeline TD



_______________________________________________
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

Reply via email to