if you don't need the thread, and you might not you're gonna wait until is done or cancel it any way :)
the very basics would be like this 1. import time 2. 3. def anyFunction(): 4. progBar = nuke.ProgressTask("Progress job") // create the progress 5. 6. for i in xrange(0, 100): 7. if progBar.isCancelled(): // handle cancel button 8. break; 9. print "doing some stuff" // what is being processed 10. progBar.setProgress(i) // set the progress percentage 11. time.sleep(0.2) // only there so you can see the progress not needed // in actual code 12. 13. anyFunction() so the range can be the number of files to copy, number of read nodes etc cheers!! .:varomix:. MIX Studio 3D Artist/Generalist TD varo...@varomix.net <varo...@gmail.com> Contact Me [image: Linkedin] <http://mx.linkedin.com/in/varomix>[image: Facebook] <http://www.facebook.com/varomix>[image: Twitter]<http://www.twitter.com/varomix> On Tue, Sep 18, 2012 at 11:56 AM, Luca Fiorentini <luca.fiorent...@gmail.com > wrote: > Thanks Nathan! > > Now it is way clearer and works like a charm! > > Kudos :) > > > On Tue, Sep 18, 2012 at 7:34 PM, Nathan Rusch <nathan_ru...@hotmail.com>wrote: > >> You’re basically on the right track. You need to run your slow >> function on a separate thread to avoid blocking Nuke’s GUI until it >> finishes, and you would create and update your progress bar from within >> that function as well so it will update properly in time with your >> processing. >> >> >> import threading >> import time >> >> def dummy(): >> task = nuke.ProgressTask('Examining Read Nodes...') >> reads = nuke.allNodes('Read') >> progIncr = 100.0 / len(reads) >> for i, r in enumerate(reads): >> if task.isCancelled(): >> nuke.executeInMainThread(nuke.message, args=('Aborted',)) >> return >> task.setProgress(int(i * progIncr)) >> task.setMessage(r.fullName()) >> # Placeholder for some long per-node process >> time.sleep(2) >> >> def aMenuCommand(): >> # This is the function you would actually bind to a Nuke menu command >> threading.Thread(target=dummy).start() >> >> >> -Nathan >> >> >> *From:* Luca Fiorentini <luca.fiorent...@gmail.com> >> *Sent:* Tuesday, September 18, 2012 10:19 AM >> *To:* nuke-python@support.thefoundry.co.uk >> *Subject:* [Nuke-python] progress bar >> >> Hi! >> >> I am trying to make a progress bar but with no success. >> I took a look at the code in the guide >> >> >> http://docs.thefoundry.co.uk/nuke/63/pythondevguide/basics.html#creating-progress-bar-dialogs >> >> But I am clearly missing something. >> Could someone kindly explain it to me in an easier way? >> Imagine I have a function like this: >> >> def dummy(): >> for n in nuke.allNodes('Read'): >> print 'here my super slow function' >> >> where and how should I implement the progress bar? >> should I use the code from the example and then call the whole funciont >> in a new thread? like >> >> threading.Thread( None, dummy ).start() >> >> Thanks for your time >> >> -- >> *Luca Fiorentini - 3D Lighting Artist* >> My Showreel <http://www.vimeo.com/lucafiorentini/reel> - My >> blog<http://lucafiorentini.wordpress.com>- My >> Flickr <http://www.flickr.com/photos/lucafiorentini> >> >> ------------------------------ >> _______________________________________________ >> 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 >> >> > > > -- > *Luca Fiorentini - 3D Lighting Artist* > My Showreel <http://www.vimeo.com/lucafiorentini/reel> - My > blog<http://lucafiorentini.wordpress.com>- My > Flickr <http://www.flickr.com/photos/lucafiorentini> > > > _______________________________________________ > 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