0

I'm not following how to use the UI type ProgressBar in pyMel.

The old way, or the derivative of this was to do this:

cmds.progressBar('barName', edit=1, progress=50)

However I can't seem to figure out how to use the pymel version of this.

This is what I've tried:

ProgressBar('barName').setProgress(50)

This doesn't work obviously, however I'd much rather use the pymel version, it's cleaner and easier to read.

Shannon Hochkins
  • 11,763
  • 15
  • 62
  • 95

1 Answers1

0

You just have to specify from which module ProgressBar() is from. Here it's ui.

ui.ProgressBar('myPBar').setProgress(50)

Argiri Kotsaris
  • 492
  • 3
  • 7
  • I'm asking how to use the ProgressBar class? Not how to build a UI? I don't want to use the derivative of the python command module, I want to use pymels class, every post on the discussion you posted is using the derivative, also, I said I don't understand the ProgressBar, I've already looked up the docs, but I don't understand it, hence why I came here :9 – Shannon Hochkins Aug 23 '13 at 00:50
  • Yes I've edited the post, and the only reason I gave you those other discussions is to understand how you can implement the UI elements in a more efficient way. i.e. creating a class and defining the UI elements in `__init__()`. – Argiri Kotsaris Aug 23 '13 at 00:54
  • You should never import pymel.core like that, http://docs.python.org/2/howto/doanddont.html#from-module-import, also, as you can see in my question I'm trying to set the progress on an existing progressbar, not create one... – Shannon Hochkins Aug 23 '13 at 01:05
  • oh that did the trick! So ProgressBar is just a way of building it, not editing it? – Shannon Hochkins Aug 23 '13 at 01:13
  • wait, isn't PyNode only referred to by a specific node? Not a UI element? because I can't get that to work :/ – Shannon Hochkins Aug 23 '13 at 01:32
  • I had to do it like this, `progressBar('barName',edit=True).setProgress(50)` – Shannon Hochkins Aug 23 '13 at 01:43
  • Yes my apologies, I've edited the post. It is assuming though that you've import PyMEL via `from pymel.core import *`. – Argiri Kotsaris Aug 23 '13 at 01:58
  • On import style, the main reason is to avoid name clashes. If pymel.core is the _only_ * import it's only mildly dangerous -- but if you do it with anything else, you're betting on your knowledge of all the APIs concerned to be sure there are no matching names. Personally I always stick with pm.blah() because I use a lot of different modules and I've been burned too often in the past... Plus, keeping the dotted names makes things easier if you use an IDE with autocomplete :0 – theodox Aug 23 '13 at 04:53