You could grab the reference to the main progress bar and connect to its 
signal:

import maya.OpenMayaUI as mui
from PySide import QtGuiimport shiboken

ptr = mui.MQtUtil.mainWindow()
win = shiboken.wrapInstance(long(ptr), QtGui.QWidget)

prog = win.findChild(QtGui.QProgressBar)print prog.objectName()
def print_progress(val):
    print "Progress!", val

prog.valueChanged.connect(print_progress)

​

But be careful not to do anything big in your slot since it will hold up 
the app :-)

Using the thread doesn't really help here since it will still place the 
call into the main event loop and as soon as your file process starts, none 
of your other code will get called. So you kind of need the slot connection 
to the progress bar since it is being used as part of that call. However, 
you could feed the progress to something else running in a thread to handle 
stuff that needs to do more work. 



On Friday, May 23, 2014 2:13:05 AM UTC+12, Marcus Ottosson wrote:
>
> Hey guys,
>
> When running an import, say of a 2 gb file, there is a progress bar 
> lurking in the Help panel. Does anyone know how to tap into that one?
>
> E.g.
>
> import timeimport threadingimport maya.cmdsimport maya.utils
>
> path = r'/home/big_file.ma'
> def thread():    
>     maya.utils.executeInMainThreadWithResult(maya.cmds.file, path, i=True)
>
> thread = threading.Thread(target=thread)
> thread.daemon = True
> thread.start()
> # I'm looking for this one, to give me# updates on progress, so that I can 
> use it# in a GUI.
> progress = None
> # Example usewhile progress:
>     print progress.value
>     time.sleep(0.1)
> print "Done"
>
> Best,
> Marcus
> ​
> -- 
> *Marcus Ottosson*
> [email protected]
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/fd54deda-6320-44dc-9eda-649a5b796dbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to