Пример #1
0
    def _newFileMenuItem(self):
        """Prompts and then creates a new file"""

        dialogs = Dialogs(self.view)

        path = self._newFileWizard()

        #see if we want to make a blank scene or not
        msg = 'How should the new file be created?'
        BLANK = 'Make a blank maya scene'
        EXISTING = 'Use a copy of an existing file'

        choice = dialogs.radioButtonDialog(msg, [BLANK, EXISTING])

        if choice == BLANK:
            msg = 'Final confirmation:'
            msg += '\n\nCreate blank maya file at "%s"?' % path
            dialogs.confirmPrompt(msg)
            self.model.createFile(path)

        elif choice == EXISTING:
            src_path = dialogs.fileDialog(
                self.model.project.getScenesDir(),
                self.model.project.getDialogFilters())

            msg = 'Please confirm:'
            msg += '\n\nCopy "%s" to new file "%s"?' % (src_path, path)
            dialogs.confirmPrompt(msg)
            self.model.copyFile(src_path, path)

        msg = 'New file successfully created!'
        msg += '\n\nLocation: %s' % path
        msg += '\n\nPlease check out your new file to begin work on it.'
        dialogs.infoPrompt(msg)
Пример #2
0
    def _newFileWizard(self):
        """Wizard that prompts the user to get the path of a new file"""

        dialogs = Dialogs(self.view)

        #get category
        category = dialogs.radioButtonDialog('Pick a category:' , 
            self.model.project.config['NEW_FILE_CATEGORIES'])

        #get name of asset/shot (loop until valid input)
        name = dialogs.fileTextPrompt('Enter name:')

        #get task
        tasks = self.model.project.config['NEW_FILE_TASKS'][category][:]
        tasks.append('Other')

        task = dialogs.radioButtonDialog('Pick a task:' , tasks)

        if task == 'Other':
            task = dialogs.textPrompt('Enter task:')

        #get the path of the file we are creating
        category_dir = self.model.project.config['NEW_FILE_PATHS'][category]
        result = os.path.join(category_dir, name, '%s_%s.mb' % (name, task))

        #ask to overwrite
        print 'EXISTS:', result, os.path.exists(result)
        if os.path.exists(result):
            msg = 'The file "%s" already exists. Overwrite?' % result
            dialogs.confirmPrompt(msg)

        #confirm all settings
        msg = 'You have selected:'
        msg += '\n\n\tCategory: %s' % category
        msg += '\n\tName: %s' % name
        msg += '\n\tTask: %s' % task
        msg += '\n\nThis will create a file in this location: '
        msg += '\n%s' % result
        msg += '\n\nDoes this look okay?'
        dialogs.confirmPrompt(msg)

        return result