Thanks - nice to know it wasn't a dumb question ;)

I'll try the os.walk().next() I think


 
Howard



>________________________________
> From: Diogo Girondi <diogogiro...@gmail.com>
>To: Howard Jones <mrhowardjo...@yahoo.com>; Nuke Python discussion 
><nuke-python@support.thefoundry.co.uk> 
>Sent: Tuesday, 18 September 2012, 21:18
>Subject: Re: [Nuke-python] progress bar
> 
>
>I usually take the same approach as Alvaro. I pre-process things to the get 
>the total number of iterations and then I start the actual process with a 
>progress bar for the whole thing.
>
>
>Another way is to leave the progress as merely an indication that something is 
>happening, going from 0 to 100 for each new iteration. This might be "better" 
>for processes that you don't know the actual "length" and take way too long to 
>process like doing a os.walk() on a huge folder structure.
>
>
>For that I do a try os.walk().next() and set the progress bar from 0 to 100 
>for each new iteration that is successful until it ends and I set the progress 
>bar to complete.
>
>
>But would be great if there was an alternative to these.
>
>
>
>
>cheers,
>diogo
>
>
>On Tue, Sep 18, 2012 at 4:54 PM, Howard Jones <mrhowardjo...@yahoo.com> wrote:
>
>Yes but that means walking twice which was something I was hoping to avoid
>>
>>
>>
>> 
>>Howard
>>
>>
>>
>>>________________________________
>>> From: Alvaro Castaneda <varo...@gmail.com>
>>>To: Howard Jones <mrhowardjo...@yahoo.com>; Nuke Python discussion 
>>><nuke-python@support.thefoundry.co.uk> 
>>>Sent: Tuesday, 18 September 2012, 20:36
>>>
>>>Subject: Re: [Nuke-python] progress bar
>>> 
>>>
>>>
>>>
>>>you can count the folders before hand using something like os.walk()
>>>
>>>
>>>http://www.saltycrane.com/blog/2007/03/python-oswalk-example/
>>>
>>>
>>>
>>>
>>>cheers!!
>>> .:varomix:.
>>>MIX Studio 
>>>3D Artist/Generalist TD
>>>varo...@varomix.net 
>>>Contact Me 
>>>
>>>
>>>
>>>
>>>On Tue, Sep 18, 2012 at 1:14 PM, Howard Jones <mrhowardjo...@yahoo.com> 
>>>wrote:
>>>
>>>Hooray - a clear explanation!
>>>>
>>>>
>>>>Out of interest what do you do if you don't know how many iterations are 
>>>>needed so in
>>>>
>>>>
>>>>progIncr = 100.0 / len(reads)
>>>>
>>>>
>>>>you cant know the value of len(reads)?
>>>>
>>>>
>>>>Say you are walking a path and dont know how many subfolders there are but 
>>>>want to show progress on the walk?
>>>>
>>>>
>>>>Cheers 
>>>>
>>>>Howard
>>>>
>>>>
>>>>
>>>>>________________________________
>>>>> From: Luca Fiorentini <luca.fiorent...@gmail.com>
>>>>>To: Nuke Python discussion <nuke-python@support.thefoundry.co.uk> 
>>>>>Sent: Tuesday, 18 September 2012, 18:56
>>>>>Subject: Re: [Nuke-python] progress bar
>>>>> 
>>>>>
>>>>>
>>>>>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 
>>>>>>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 - My blog - My 
Flickr
>>>>>>
>>>>>>
>>>>>>________________________________
>>>>>> _______________________________________________
>>>>>>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 - My blog - My Flickr
>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>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
>>>>
>>>>
>>>
>>>
>>>
>>_______________________________________________
>>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