def pick_file(file_ext='', files_filter='', init_dir='', restore_dir=True, multi_file=False, unc_paths=False): of_dlg = Forms.OpenFileDialog() if files_filter: of_dlg.Filter = files_filter else: of_dlg.Filter = '|*.{}'.format(file_ext) of_dlg.RestoreDirectory = restore_dir of_dlg.Multiselect = multi_file if init_dir: of_dlg.InitialDirectory = init_dir if of_dlg.ShowDialog() == Forms.DialogResult.OK: if unc_paths: return coreutils.dletter_to_unc(of_dlg.FileName) return of_dlg.FileName
def save_file(file_ext='', files_filter='', init_dir='', default_name='', restore_dir=True, unc_paths=False): sf_dlg = Forms.SaveFileDialog() if files_filter: sf_dlg.Filter = files_filter else: sf_dlg.Filter = '|*.{}'.format(file_ext) sf_dlg.RestoreDirectory = restore_dir if init_dir: sf_dlg.InitialDirectory = init_dir # setting default filename sf_dlg.FileName = default_name if sf_dlg.ShowDialog() == Forms.DialogResult.OK: if unc_paths: return coreutils.dletter_to_unc(sf_dlg.FileName) return sf_dlg.FileName