Hmm, on second thought, patching the module with a subclass probably won’t work 
due to parent recursion issues, but you could just replace the dialog class 
completely:


import externalModule

class MyDialog(nukescripts.panels.PythonPanel):
    # Do whatever you want, but make sure your version has the
    # same interface as the original
    pass

# Assuming DialogClass is the class used by the function you want to call
externalModule.DialogClass = MyDialog


-Nathan



From: Dennis Serras 
Sent: Thursday, November 07, 2013 3:40 PM
To: Nuke Python discussion 
Subject: RE: [Nuke-python] Filling out a PythonPanel from a different script

OK Nathan, monkey-patching sounds like a lot of fun, but I’m not sure it’s 
legal here in Burbank… ;^) How do I do that without changing the original 
module? The problem is that the team which created the original module updates 
it frequently, and is not affiliated with my team, so I can’t nicely ask them 
to make changes. Essentially, theirs renders multiple nodes, with a dialog at 
the beginning. What I want is to run their script on each node one at a time, 
and fill in their popup each time it appears (or replace it, if possible). 
Assuming they don’t change their function names, it should be a lot easier for 
me to keep up with their code updates.

 

 

den serras 

                      @ stereoD

 

From: nuke-python-boun...@support.thefoundry.co.uk 
[mailto:nuke-python-boun...@support.thefoundry.co.uk] On Behalf Of Nathan Rusch
Sent: Thursday, November 07, 2013 3:08 PM
To: Nuke Python discussion
Subject: Re: [Nuke-python] Filling out a PythonPanel from a different script

 

So if I understand your situation correctly, you’re calling a function in 
another module (which you don’t want to modify), and that function is creating 
this dialog you *do* want to modify.

 

Simple solution: subclass the dialog, then monkey-patch the original module to 
replace the dialog class with your subclass.

 

 

-Nathan

 

From: Dennis Serras 

Sent: Thursday, November 07, 2013 2:32 PM

To: Nuke Python discussion 

Subject: RE: [Nuke-python] Filling out a PythonPanel from a different script

 

Hm this method may not work… Nuke hangs while the original panel is open, so I 
can’t get my script to find it to fill in the fields.

 

Thanks for the advice!

 

 

den serras 

                      @ stereoD

 

From: nuke-python-boun...@support.thefoundry.co.uk 
[mailto:nuke-python-boun...@support.thefoundry.co.uk] On Behalf Of Jordan O
Sent: Thursday, November 07, 2013 1:50 PM
To: Nuke Python discussion
Subject: Re: [Nuke-python] Filling out a PythonPanel from a different script

 

do you have still have access to the panel object? I'm still not sure I 
understand you fully, but this is how I'd go about modifying an existing panel.

 

 

For example, in my case I have an instance as t:

 

t=TestPanel()

t.show()

 

t.frameRangeKnob.setValue('blah')

k = nuke.AColor_Knob('asdf')

t.addKnob( k )

t.removeKnob( k ) 

All these commands can modify the panel after being shown.

 

 

 

Or, if you don't have access to the panel but you know the class name, perhaps 
something like this might do the trick?

def find_panels():

    results = []

    for instance in globals():

        if isinstance( eval( instance ), TestPanel  ):

            results.append( instance )

    return results

 

It's a little dirty, but should do the trick.

 

 

 

On Fri, Nov 8, 2013 at 10:33 AM, Dennis Serras <dennis.ser...@bydeluxe.com> 
wrote:

Someone else’s code creates the popup – I can’t do anything to that code except 
run it... I have to launch their script with my script, and somehow fillout 
their popup, if that’s possible. If not, then I need to fork their code, which 
I’m really trying to avoid.

 

 

den serras 

                      @ stereoD

 

From: nuke-python-boun...@support.thefoundry.co.uk 
[mailto:nuke-python-boun...@support.thefoundry.co.uk] On Behalf Of Jordan O
Sent: Thursday, November 07, 2013 1:29 PM
To: Nuke Python discussion
Subject: Re: [Nuke-python] Filling out a PythonPanel from a different script

 

Ok, so simple enough, you're making a python panel, adding knobs.

I'm still not sure what you mean by "fill it out" or what it is you'd like to 
do with this panel?

cheers,

Jordan

 

 

On Fri, Nov 8, 2013 at 10:19 AM, Dennis Serras <dennis.ser...@bydeluxe.com> 
wrote:

Dangit, I knew I’d forget to change the header (for an email I started a week 
ago but never needed to send).

 

The PythonPanel comes from a class call with an __init__ that launches the 
panel:

 

    def __init__(self, job, shot):

        nukescripts.PythonPanel.__init__(self, 'Render Submission')

        first = int(nuke.root()['first_frame'].value())

        last = int(nuke.root()['last_frame'].value())

        self.frameRangeKnob = nuke.String_Knob('fRange', 'Frame Range', '%s-%s' 
% (first, last))

        self.addKnob(self.frameRangeKnob)

 

 

 

den serras 

                      @ stereoD

 

From: nuke-python-boun...@support.thefoundry.co.uk 
[mailto:nuke-python-boun...@support.thefoundry.co.uk] On Behalf Of Jordan O
Sent: Thursday, November 07, 2013 1:10 PM
To: Nuke Python discussion
Subject: Re: [Nuke-python] Finding common & unique "words" in a string

 

Hi Dennis,

 

Could you give a little bit more information? E.g. any example code of the 
pythonpanel declaration?

And by "filling out" do you mean removing existing knobs and adding your own?

 

cheers,

Jordan

 

On Fri, Nov 8, 2013 at 9:56 AM, Dennis Serras <dennis.ser...@bydeluxe.com> 
wrote:

Hi folks – I have an odd one. I need to fill in a pythonpanel popup that comes 
from a different script. I have access to the other code, but I cannot change 
it. I don’t want to fork their code if I can help it. Anyone know if filling 
out a pythonpanel created by a different function is possible?

 

 

 

den serras

   @  

     senior technical artist  | stereo D | deluxe 3D


This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed. 


_______________________________________________
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

 


This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed. 


_______________________________________________
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

 


This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed. 


_______________________________________________
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

 


This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed. 


--------------------------------------------------------------------------------

_______________________________________________
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


This e-mail and any attachments are intended only for use by the addressee(s) 
named herein and may contain confidential information. If you are not the 
intended recipient of this e-mail, you are hereby notified any dissemination, 
distribution or copying of this email and any attachments is strictly 
prohibited. If you receive this email in error, please immediately notify the 
sender by return email and permanently delete the original, any copy and any 
printout thereof. The integrity and security of e-mail cannot be guaranteed. 


--------------------------------------------------------------------------------
_______________________________________________
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