def promptForPath(**kwargs): """ Prompt the user for a folder path """ if cmds.about(linux=1): return _Path(fileDialog(**kwargs)) else: # a little trick that allows us to change the top-level 'folder' variable from # the nested function ('getfolder') - use a single-element list, and change its content folder = [None] def getfolder(*args): folder[0] = args[0] kwargs.pop('fileCommand',None) kwargs['fc'] = getfolder if 'mode' not in kwargs: kwargs['mode'] = 0 kwargs['an'] = kwargs.pop('an', kwargs.pop('actionName', "Select File")) ret = cmds.fileBrowserDialog(**kwargs) folder = _Path(folder[0]) if folder: #Ensure something was entered/selected. But don't test if it exists # as this would break mode 1/100+ causing them to return None return folder
def promptForPath(**kwargs): """ Prompt the user for a folder path """ if cmds.about(linux=1): return _Path(fileDialog(**kwargs)) else: # a little trick that allows us to change the top-level 'folder' variable from # the nested function ('getfolder') - use a single-element list, and change its content folder = [None] def getfolder(*args): folder[0] = args[0] kwargs.pop('fileCommand', None) kwargs['fc'] = getfolder if 'mode' not in kwargs: kwargs['mode'] = 0 kwargs['an'] = kwargs.pop('an', kwargs.pop('actionName', "Select File")) ret = cmds.fileBrowserDialog(**kwargs) folder = _Path(folder[0]) if folder: # Ensure something was entered/selected. But don't test if it exists # as this would break mode 1/100+ causing them to return None return folder
def __new__(cls, msgOrException, title='Error', button='Ok', msg=None, icon='critical'): if not isinstance(msgOrException, (basestring, Exception)): raise TypeError(msgOrException) if not cmds.about(batch=1): if not isinstance(msgOrException, Exception): msg = msgOrException elif msg is None: args = getattr(msgOrException, 'args', []) if args: msg = args[0] else: msg = '' confirmDialog(title=title, message=msg, button=button, icon=icon) if isinstance(msgOrException, Exception): return msgOrException else: return super(PopupError, cls).__new__(cls, msgOrException)
def promptForPath(**kwargs): """ Prompt the user for a folder path """ if cmds.about(linux=1): return _Path(fileDialog(**kwargs)) else: # a little trick that allows us to change the top-level 'folder' variable from # the nested function ('getfolder') - use a single-element list, and change its content folder = [None] def getfolder(*args): folder[0] = args[0] kwargs.pop('fileCommand',None) kwargs['fc'] = getfolder kwargs['an'] = kwargs.pop('an', kwargs.pop('actionName', "Select File")) ret = cmds.fileBrowserDialog(**kwargs) folder = _Path(folder[0]) if folder.exists(): return folder
def __init__(self, msg): Exception.__init__(self, msg) if not cmds.about(batch=1): ret = informBox("Error", msg)