Пример #1
0
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
Пример #2
0
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
Пример #3
0
 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)
Пример #4
0
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
Пример #5
0
    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)
Пример #6
0
 def __init__(self, msg):
     Exception.__init__(self, msg)
     if not cmds.about(batch=1):
         ret = informBox("Error", msg)