def get_sp_file(): dialog = OpenFileDialog() dialog.Title = "Select Shared Parameters file" dialog.Filter = "TXT|*.txt" if not dialog.ShowDialog(): return with codecs.open(dialog.FileName, 'r', 'utf-16') as f: data = f.read() if '# This is a Revit shared parameter file.' not in data: return return dialog.FileName
def BtnBrowse_Click(self, sender, e): try: dlgOrg = OpenFileDialog() dlgOrg.Title = "Select orginal picture" dlgOrg.DefaultExt = ".jpg" dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif" dlgMask = OpenFileDialog() dlgMask.Title = "Select mask picture" dlgMask.DefaultExt = ".tif" dlgOrg.Filter = "JPG|*.jpg|PNG|*.png|TIF|*.tif" if dlgOrg.ShowDialog(self): if dlgMask.ShowDialog(self): print(dlgOrg.FileName) print(dlgMask.FileName) self.img.Source = BitmapImage(Uri(dlgOrg.FileName)) self.imgResult.Source = BitmapImage(Uri(dlgMask.FileName)) #import Test except e: print("Error: {}", e) return 0
def HandleimportBtn(sender, args): #Create a File open dialog dialog = OpenFileDialog() dialog.Title = "Select CSV file(s)" #Configure for single file selection dialog.Multiselect = True #Set up the file types you want to support dialog.Filter = "CSV Files|*.csv|All Files|*.*" global selectedFiles if dialog.ShowDialog(): selectedFiles = dialog.FileNames numOfTrajectories.Text = " {0} file(s)".format(len(selectedFiles))
def HandleimportBtn(sender, args): # Create a File open dialog dialog = OpenFileDialog() dialog.Title = "Select CSV file(s)" # Configure for single file selection dialog.Multiselect = True # Set up the file types you want to support dialog.Filter = "CSV Files|*.csv|All Files|*.*" # Display the dialog # If it returns anything # get the file name global selectedFiles if dialog.ShowDialog(): selectedFiles = dialog.FileNames fileNameTextBox.Text = str(len(selectedFiles))
def get_interference(): dialog = OpenFileDialog() dialog.Title = "Select interference report" dialog.Filter = "HTML|*.html" if not dialog.ShowDialog(): sys.exit() with codecs.open(dialog.FileName, 'r', 'utf-16') as f: data = f.read() if 'Interference Report' not in data: sys.exit() pattern = re.compile( r'<td>.+id (\d+)\s+</td>\s+<td>.+id (\d+)\s+</td>\s+') m = re.findall(pattern, data) ret = [] for key, group in itertools.groupby(m, lambda x: x[0]): li = [key] for i in group: li.append(i[1]) ret.append(li) return ret
def pickFile(config): dialog = OpenFileDialog() dialog.Title = config['title'] if 'title' in config else 'Pick file' # dialog.InitialDirectory = config['initialDirectory'] if 'initialDirectory' in config else None # TODO FIXME dialog.Multiselect = True if 'multiselect' in config and config[ 'multiselect'] else False # # TODO FIXME # if 'filter' in config: # for f in config['filter']: # dialog.Filter = '{}|({});{}|'.format(f[0], f[1], f[1]) result = dialog.ShowDialog() if result: if 'read' in config and config['read'] and 'multiselect' not in config: with open(dialog.FileName, 'r') as f: return f.read() else: if 'multiselect' in config and config['multiselect']: return list(dialog.FileNames) else: return dialog.FileName