paleo_view_v1_2.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:PaleoView 作者: GlobalEcologyLab 项目源码 文件源码
def selectGenerationDirectory(self) :

        # Place focus on select directory button
        self.generation_directory_button.focus_set()

        # Reset generation
        self.resetGeneration()

        # Get current config tool options
        tool_option_values = self.getToolOptions()

        # Use existing/last used generation directory if it exists otherwise use default directory
        if self.data_file_helper.getFileGenerationDirectoryPath() and path.exists(self.data_file_helper.getFileGenerationDirectoryPath()) :
            initial_directory = self.data_file_helper.getFileGenerationDirectoryPath()
        elif tool_option_values['default_file_generation_directory'] and path.exists(tool_option_values['default_file_generation_directory']) :
            initial_directory = tool_option_values['default_file_generation_directory']
        elif MAC_VERSION and environ.has_key('HOME') and path.exists(environ['HOME']) :
            initial_directory = environ['HOME']
        elif environ.has_key('USERPROFILE') and path.exists(environ['USERPROFILE']) : # PC version
            initial_directory = environ['USERPROFILE']
        else :
            initial_directory = getcwd()

        # Open file selection dialog
        generation_directory_path = askdirectory(title='Select the directory to generate files', initialdir=initial_directory)

        if generation_directory_path : # Directory selected

            # Create directory if it doesn't already exist
            if not path.exists(generation_directory_path) :
                try :
                    generation_directory_path = self.data_file_helper.createDirectoryPath(generation_directory_path)
                except Exception, e :
                    directory_name = self.data_file_helper.splitPath(generation_directory_path)['name']
                    showerror('Directory Error', 'Error loading or creating directory \"'+directory_name+'\". Check file permissions.')
                    print >> sys.stderr, 'Error loading or creating directory:', e

            # Set path
            generation_directory_path = path.normpath(str(generation_directory_path))
            self.data_file_helper.setFileGenerationDirectory(generation_directory_path)
            location_descr = 'File generation in \"' + self.data_file_helper.getFileGenerationDirectoryName() + '\"'
            self.generation_directory_label_text.set(location_descr)

            # Set default when not already set via config options
            if not tool_option_values['default_file_generation_directory'] or not path.exists(tool_option_values['default_file_generation_directory']) or not tool_option_values['default_file_generation_directory_set'] :
                self.setToolOptions({ 'default_file_generation_directory' : generation_directory_path })

            # Enable the generate button
            self.generate_button.configure(state=tk.NORMAL)

    # Step 7 Method: Generate Data Files
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号