def selectDefaultFileGenerationDirectory(self) :
# Get current config tool options
tool_option_values = self.getToolOptions()
# Use existing Default File Generation Directory if it exists
if 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
default_file_generation_directory_path = askdirectory(title='Select the default directory for output files', initialdir=initial_directory)
if default_file_generation_directory_path : # Directory selected
# Create directory if it doesn't already exist
if not path.exists(default_file_generation_directory_path) :
try :
default_file_generation_directory_path = self.data_file_helper.createDirectoryPath(default_file_generation_directory_path)
except Exception, e :
directory_name = self.data_file_helper.splitPath(default_file_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 the directory
default_file_generation_directory_path = path.normpath(str(default_file_generation_directory_path))
self.data_file_helper.setFileGenerationDirectory(default_file_generation_directory_path)
location_descr = 'File generation in \"' + self.data_file_helper.getFileGenerationDirectoryName() + '\"'
self.generation_directory_label_text.set(location_descr)
self.default_file_generation_directory_location.set(default_file_generation_directory_path)
self.setToolOptions({ 'default_file_generation_directory' : default_file_generation_directory_path, 'default_file_generation_directory_set' : True })
# Enable the generate button
self.generate_button.configure(state=tk.NORMAL)
# Reset focus to config window
self.config_default_file_generation_directory_window.focus_set()
# Menu Method: Download Climate Data
评论列表
文章目录