def __init__(self): self.Text = "Spreadsheet to HTML" self.Width = 220 self.Height = 90 self.FormBorderStyle = FormBorderStyle.Fixed3D self.openDialog = OpenFileDialog() self.openDialog.Title = "Choose a Python Spreadsheet File" self.openDialog.Filter = 'Python files (*.py)|*.py|All files (*.*)|*.*' self.folderDialog = FolderBrowserDialog() self.folderDialog.ShowNewFolderButton = True self.folderDialog.Description = "Choose a directory to save the HTML files in." l = Label() l.AutoSize = True l.Location = Point(50, 5) l.Text = "Choose a Spreadsheet" b = Button(Text="Choose") b.Click += self.convert b.Location = Point(70, 30) self.Controls.Add(l) self.Controls.Add(b)
def buttonAttach_Click(self, sender, e): openFile = OpenFileDialog() openFile.Multiselect = True openFile.ShowDialog() self.add_attachments(openFile.FileNames) self.comboBoxAttachments.Visibility = Visibility.Visible
def key(self, sender, e): dialog = OpenFileDialog() dialog.Filter = "PNG or BMP or Tif files(*.png,*.bmp,*.tif)|*.png;*.tif;*.bmp" dialog.ShowDialog() if dialog.OnFileOk: if dialog.FileName != "": dir = os.getcwd() g = "Text/path.txt" i = open(g,"w") i.write(dialog.FileName) i.close() dir3 = dir + "\\files\\a\\dist\\black_and_white.exe" #p = subprocess.Popen(py_dir + "\python.exe " + dir + "\\black_and_white.py",shell=True) p = subprocess.Popen(dir3,shell=True) p.wait() #os.system(py_dir + "\python.exe " + dir + "\\black_and_white1.py") data = dialog.FileName self.ke.Content = str(data) MessageBox.Show("Choose the 'first noise' panel","Note!",MessageBoxButton.OK, MessageBoxImage.Information) self.k_panel.IsEnabled = False self.f_panel.IsEnabled = True self.f_panel.IsSelected = True self.panel = "f" f = open("Text/picsaz.txt","w") f.write(str(data)+"\n") self.key = data pass
def get_script_filenames(): file_dialog = OpenFileDialog() file_dialog.Filter = 'R scripts (*.R)|*.R|All files (*.*)|*.*' file_dialog.Multiselect = True if file_dialog.ShowDialog() != DialogResult.OK: return [] return list(file_dialog.FileNames)
def ask_for_file(typ, exts): dlg = OpenFileDialog() dlg.Filter = typ + ' (' + ', '.join( ['*.' + e for e in exts]) + ')|' + ';'.join(['*.' + e for e in exts]) dlg.Multiselect = False ret = dlg.ShowDialog() return dlg.FileName if ret == DialogResult.OK else None
def Open_File_dialog(self): """description of class""" dialog = OpenFileDialog() dialog.Filter = self.filter if dialog.ShowDialog() == DialogResult.OK: self.file_list.append(dialog.FileName) return True return False
def __addFileToTask(self, caller, eventArgs): oDialog = OpenFileDialog() oDialog.Title = 'Select File to Erase' oDialog.Filter = 'All files (*.*)|*.*' if oDialog.ShowDialog() == DialogResult.OK: self.conDict['dGrid'].Items.Add(oDialog.FileName)
def GetAMPLDataPath(key, e): dialog = OpenFileDialog() dialog.Filter = "AMPL data files (*.dat)|*.dat" myDialog = dialog.ShowDialog() if (myDialog == DialogResult.OK): return dialog.FileName elif (myDialog == DialogResult.Cancel): return "CANCELLED"
def GetGDXPath(sender, event): dialog = OpenFileDialog() dialog.Filter = "GDX files (*.gdx)|*.gdx" myDialog = dialog.ShowDialog() if (myDialog == DialogResult.OK): return dialog.FileName elif (myDialog == DialogResult.Cancel): return "CANCELLED"
def OnClicked(self, sender, event): dialog = OpenFileDialog() dialog.Filter = "C# files (*.cs)|*.cs" if dialog.ShowDialog(self) == DialogResult.OK: f = open(dialog.FileName) data = f.read() f.Close() self.textbox.Text = data
def GetGDXPath(sender,event): dialog = OpenFileDialog() dialog.Filter = "GDX files (*.gdx)|*.gdx" dialog.InitialDirectory = SolverStudio.WorkingDirectory() myDialog = dialog.ShowDialog() if (myDialog == DialogResult.OK): return dialog.FileName elif (myDialog == DialogResult.Cancel): return "CANCELLED"
def do_open_dialog(): dlg = OpenFileDialog() dlg.Title = "Import Column Settings" dlg.FileName = "Column Import" dlg.Filter = 'MahTweets Settings (*.mahtweets) | *.mahtweets' if dlg.ShowDialog() == DialogResult.OK: return dlg.FileName else: return None
def file_tb_MouseDoubleClick(self, sender, e): dialog = OpenFileDialog() dialog.Filter = "EXCEL files (*.xlsx)|*.xlsx" if dialog.ShowDialog() == DialogResult.OK: self.xlsx_path = dialog.FileName self.file_tb.Text = self.xlsx_path AddWarningMessage(self.xlsx_path) else: pass
def buttonPressed(self, sender, args): #try: #except Exception as ex: #print ex #raw_input() dialog = OpenFileDialog() dialog.Filter = "All Files|*.*" if dialog.ShowDialog() == True: pass self.FilePath = dialog.FileName self.TextBox.Text = dialog.FileName
def get_file(): dialog = OpenFileDialog() dialog.Filter = "All Files|*.*" result = dialog.ShowDialog() Path_File = '' if result == DialogResult.OK: Path_File = dialog.FileName if Path_File: return Path_File else: return None
def EditValue(self, context, provider, value) : dialog = OpenFileDialog() dialog.Filter = "MP3 files (*.mp3)|*.mp3|All files (*.*)|*.*" dialog.InitialDirectory = Environment.SpecialFolder.Recent.ToString(); if dialog.ShowDialog() == DialogResult.OK : value = dialog.FileName dialog.Dispose() return value
def RestorelStripMenuItem1Click(self, sender, e): openFileDialog = OpenFileDialog() openFileDialog.Filter = 'Data Manager rule set (*.dat)|*.dat' if openFileDialog.ShowDialog() == DialogResult.OK: self.writeRuleFile() self.loadGroups() try: File.Copy(globalvars.DATFILE,globalvars.BAKFILE,True) File.Copy(openFileDialog.FileName, globalvars.DATFILE, True) self.showTheFile() except Exception, err: MessageBox.Show('Could not restore file.\n%s' % str(err), 'Data Manager for ComicRack %s' % self.theVersion)
def win_dialog_thread(arg): print(f"dialog_thread started") folder_dialog = FolderBrowserDialog() file_dialog = OpenFileDialog() title = arg.Dequeue() initial_folder = arg.Dequeue() print(f"title: {title}, initial_folder: {initial_folder}") folder_dialog.Description = title folder_dialog.SelectedPath = initial_folder folder_dialog_result = folder_dialog.ShowDialog() file_dialog_result = file_dialog.ShowDialog() selected_folder = folder_dialog.SelectedPath selected_file = file_dialog.FileName win_dialog_result = selected_folder, selected_file arg.Enqueue(win_dialog_result) print(f"win_dialog_thread completed, {win_dialog_result}")
def file_path(): import sys import ctypes co_initialize = ctypes.windll.ole32.CoInitialize co_initialize(None) import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import OpenFileDialog file_dialog = OpenFileDialog() ret = file_dialog.ShowDialog() if ret != 1: print("Cancelled") sys.exit() return file_dialog.FileName
def __init__(self): self.Text = "OpenDialog" self.Height = 140 self.Width = 376 self.MinimizeBox = False self.MaximizeBox = False self.CenterToScreen() self.label = Label() self.label.Text = "you can type *.png or *.jpg to find your purpose file, we put *.png for your help" self.label.Location = Point(0, 0) self.label.Height = 30 self.label.Width = 380 button = Button() button.Text = "Continue" button.Location = Point(0, 30) button.Height = 70 button.Width = 360 button.Click += self.buttonPressed self.Controls.Add(self.label) self.Controls.Add(button) self.Show() dialog = OpenFileDialog() dialog.Filter = "PNG or BMP or Tif files(*.png,*.bmp,*.tif)|*.png;*.tif;*.bmp" if dialog.ShowDialog(self) == DialogResult.OK: #data = dialog.FileNames f = open("Text/path.txt","w") f.write(dialog.FileName + "\n") f.close() else: f = open("Text/path.txt","w") f.write("cancel\n") f.close()
def abreFichero(self, sender, event): color = OpenFileDialog() color.Filter = "Ficheros txt (*.txt)|*.txt" color.Title = "Selecciona un fichero de texto" nombre = "" if (color.ShowDialog() == DialogResult.OK ): nombre = color.FileName self.label2.Text = "Fichero seleccionado: " + nombre # cargamos el texto fichero = File.OpenText(nombre) texto = "" s = fichero.ReadLine() while s : texto += s s = fichero.ReadLine() self.areaTexto.Text = texto
def pick_file(file_ext='', multi_file=False): of_dlg = OpenFileDialog() of_dlg.Filter = '|*.{}'.format(file_ext) of_dlg.RestoreDirectory = True of_dlg.Multiselect = multi_file if of_dlg.ShowDialog() == DialogResult.OK: return of_dlg.FileName
def _pick_sound_file(title, local_path): dialog = OpenFileDialog() dialog.Title = title dialog.InitialDirectory = Environment.GetEnvironmentVariable("USERPROFILE") dialog.Filter = "mp3 files (*.mp3)|*.mp3" if dialog.ShowDialog() == DialogResult.OK: os.system('copy "{0}" "{1}"'.format(dialog.FileName, local_path)) Parent.PlaySound(local_path, 1)
def getcsvname(): themodel = wfl.GetModelByPartialName("wflow") dialog = OpenFileDialog() if themodel: dialog.InitialDirectory = os.path.join( themodel.DirectoryPath, themodel.DefaultOutputDirectoryName) else: dialog.InitialDirectory = "C:\\" dialog.Filter = "csv files (*.csv) | *.csv" dialog.FilterIndex = 1 dialog.RestoreDirectory = False dialog.Title = "Select a WFlow result csv file: " if dialog.ShowDialog() == DialogResult.OK: thefile = dialog.FileName return thefile
def file_path(): # Get operating system operating_system = platform.system() if operating_system == 'Windows': # Windows, use default import ctypes co_initialize = ctypes.windll.ole32.CoInitialize co_initialize(None) import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import OpenFileDialog file_dialog = OpenFileDialog() ret = file_dialog.ShowDialog() if ret != 1: print("Cancelled") sys.exit() return file_dialog.FileName else: # posix/linux/macos, use tkinter return tk_get_file_path()
def pick_file(file_ext='', files_filter='', init_dir='', restore_dir=True, multi_file=False, unc_paths=False): of_dlg = 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() == DialogResult.OK: if unc_paths: return dletter_to_unc(of_dlg.FileName) return of_dlg.FileName
def getcsvname(): themodel = wfl.GetModelByPartialName('wflow') dialog = OpenFileDialog() if themodel: dialog.InitialDirectory = os.path.join(themodel.DirectoryPath,themodel.DefaultOutputDirectoryName) else: dialog.InitialDirectory ="C:\\" dialog.Filter = "csv files (*.csv) | *.csv" dialog.FilterIndex = 1 dialog.RestoreDirectory = False dialog.Title = "Select a WFlow result csv file: " if (dialog.ShowDialog() == DialogResult.OK): thefile = dialog.FileName return thefile
def main(): doc = __revit__.ActiveUIDocument.Document app = __revit__.Application # Get input obj fileDialog = OpenFileDialog() fileDialog.Filter = "OBJ Geometry Format (*.obj)|*.obj|All files (*.*)|*.*" if fileDialog.ShowDialog() == DialogResult.OK: fileName = fileDialog.FileName else: sys.exit() # Start counting runtime start = time.time() # Open obj file scene = open(fileName, 'r') for line in scene: split = line.split() # If line is blank if not len(split): continue # Get geometry vertices if split[0] == "v": vertex = map(lambda x: float(x), split[1:]) vertices.append(XYZ(vertex[0], vertex[2], vertex[1])) # Get texture vertices elif split[0] == "vt": textures.append(split[1:]) # Get index of vertex elif split[0] == "f": index = list() if 2 < len(split[1:]) < 5: for i in split[1:]: # If face contain texture infomation if "/" in i: index.append(int(i.split("/")[0])) # If face does not contain texture infomation else: index.append(int(i)) indices.append(index) # Close obj file scene.close() # Build Tessellated Shape Proxy graphicStyle = FilteredElementCollector(doc).OfClass( GraphicsStyle).ToElements() defaultMaterial = ElementId(23) graphicStyle = ElementId(132) builder = TessellatedShapeBuilder() builder.OpenConnectedFaceSet(False) for index in indices: loopVertices = List[XYZ](4) for i in index: loopVertices.Add(vertices[i - 1]) tessellatedFace = TessellatedFace(loopVertices, defaultMaterial) builder.AddFace(tessellatedFace) builder.CloseConnectedFaceSet() builder.Target = TessellatedShapeBuilderTarget.AnyGeometry builder.Fallback = TessellatedShapeBuilderFallback.Mesh builder.GraphicsStyleId = graphicStyle builder.Build() result = builder.GetBuildResult() # Create Direct Shape trans = Transaction(doc, 'DirectShape') trans.Start() try: directShape = DirectShape.CreateElement( doc, ElementId(BuiltInCategory.OST_GenericModel)) directShape.ApplicationId = str(app.ActiveAddInId) directShape.SetName(objectName) directShape.SetShape(result.GetGeometricalObjects()) trans.Commit() except Exception as error: print(error) trans.RollBack() # End counting runtime time.sleep(1) end = time.time() print("Runtime of program is {}".format(end - start))
def GetFileList(): dlgFile = OpenFileDialog() dlgFile.Title = "Select files to change" dlgFile.Filter = "Wave files (*.wav)|*.wav" dlgFile.InitialDirectory = Settings.Instance().DataDir dlgFile.CheckFileExists = True dlgFile.CheckPathExists = True dlgFile.AddExtension = True dlgFile.AutoUpgradeEnabled = True dlgFile.DefaultExt = "wav" dlgFile.Multiselect = True dlgFile.RestoreDirectory = True dlgFile.SupportMultiDottedExtensions = True dlgFile.FileName = "" result = dlgFile.ShowDialog() if (result == DialogResult.OK): Settings.Instance().DataDir = Path.GetDirectoryName(dlgFile.FileName) return dlgFile.FileNames else: return
from WflowDeltashell.plotcsv import * from WflowDeltashell.wflib import * # Needed if this .net thing is not loaded yet import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import OpenFileDialog, DialogResult one = "c:\\repos\wflow-git\\examples\\wflow_rhine_sbm\\pmult\\store.csv" two = "c:\\repos\wflow-git\\examples\\wflow_rhine_sbm\\run_default\\store.csv" themodel = wfl.GetModelByPartialName("wflow") dialog = OpenFileDialog() if themodel: dialog.InitialDirectory = os.path.join(themodel.DirectoryPath, themodel.DefaultOutputDirectoryName) else: dialog.InitialDirectory = "C:\\" dialog.Filter = "csv files (*.csv) | *.csv" dialog.FilterIndex = 1 dialog.RestoreDirectory = False dialog.Title = "Select a WFlow result csv file: " if dialog.ShowDialog() == DialogResult.OK: thefile = dialog.FileName casename = os.path.dirname(os.path.dirname(thefile))
class CreateHTMLForm(Form): """ A form to create HTML files (web pages) from Resolver spreadsheets exported as code. You first choose the file to load and then the directory to put the output files in. """ def __init__(self): self.Text = "Spreadsheet to HTML" self.Width = 220 self.Height = 90 self.FormBorderStyle = FormBorderStyle.Fixed3D self.openDialog = OpenFileDialog() self.openDialog.Title = "Choose a Python Spreadsheet File" self.openDialog.Filter = 'Python files (*.py)|*.py|All files (*.*)|*.*' self.folderDialog = FolderBrowserDialog() self.folderDialog.ShowNewFolderButton = True self.folderDialog.Description = "Choose a directory to save the HTML files in." l = Label() l.AutoSize = True l.Location = Point(50, 5) l.Text = "Choose a Spreadsheet" b = Button(Text="Choose") b.Click += self.convert b.Location = Point(70, 30) self.Controls.Add(l) self.Controls.Add(b) def convert(self, sender, event): # Present the file dialog to choose a file if self.openDialog.ShowDialog() != DialogResult.OK: return filePath = self.openDialog.FileName try: # Load the spreadsheet print 'Loading spreadsheet' workbook = LoadSpreadsheet(filePath) except Exception, e: MessageBox.Show( "An error has occurred:\r\n%s: %s" % (e.__class__.__name__, e), "An Error has Occurred", MessageBoxButtons.OK, MessageBoxIcon.Warning) # Print the full traceback to the console for debugging traceback.print_exc() return # Choose a folder to place output files if self.folderDialog.ShowDialog() != DialogResult.OK: return outputDirectory = self.folderDialog.SelectedPath spreadsheetName = Path.GetFileNameWithoutExtension(filePath) # Create html as strings in a dictionary keyed by worksheet name # Will save images from ImageWorksheets print 'Creating HTML' worksheetsAsHtml = HtmlFromWorkBook(workbook, spreadsheetName, outputDirectory) # Save the output html files for name, text in worksheetsAsHtml: print 'Writing %s' % (name + '.html') try: path = Path.Combine(outputDirectory, name + '.html') h = open(path, 'w') h.write(text) h.close() except Exception, e: MessageBox.Show( "An error has occurred:\r\n%s: %s" % (e.__class__.__name__, e), "An Error has Occurred", MessageBoxButtons.OK, MessageBoxIcon.Warning) return
import sys import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import DialogResult, OpenFileDialog dialog = OpenFileDialog() dialog.Title = 'Select CAD(.sat) File' dialog.Filter = "sat files (*.sat)|*.sat" if dialog.ShowDialog() == DialogResult.OK: sat_path = dialog.FileName else: pass import ScriptEnv ScriptEnv.Initialize("Ansoft.ElectronicsDesktop") oDesktop.RestoreWindow() oDesktop.ClearMessages("","",2) oProject = oDesktop.GetActiveProject() oProject.Save() oDesign = oProject.GetActiveDesign() design_name = oDesign.GetName() oEditor = oDesign.SetActiveEditor("3D Modeler") def getMaterial(): result = {} for i in range(oEditor.GetNumObjects()): name = oEditor.GetObjectName(i) material = oEditor.GetPropertyValue('Geometry3DAttributeTab', name, 'Material').replace('"', '') color = oEditor.GetPropertyValue('Geometry3DAttributeTab', name, 'Color') result[name] = (material, color)
def openfile(self, sender, event): ofd = OpenFileDialog() dr = ofd.ShowDialog() if dr == DialogResult.OK: sender.Text = ofd.FileName
from WflowDeltashell.plotcsv import * from WflowDeltashell.wflib import * # Needed if this .net thing is not loaded yet import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import OpenFileDialog, DialogResult one = 'c:\\repos\wflow-git\\examples\\wflow_rhine_sbm\\pmult\\store.csv' two = 'c:\\repos\wflow-git\\examples\\wflow_rhine_sbm\\run_default\\store.csv' themodel = wfl.GetModelByPartialName('wflow') dialog = OpenFileDialog() if themodel: dialog.InitialDirectory = os.path.join(themodel.DirectoryPath,themodel.DefaultOutputDirectoryName) else: dialog.InitialDirectory ="C:\\" dialog.Filter = "csv files (*.csv) | *.csv" dialog.FilterIndex = 1 dialog.RestoreDirectory = False dialog.Title = "Select a WFlow result csv file: " if (dialog.ShowDialog() == DialogResult.OK): thefile = dialog.FileName casename = os.path.dirname(os.path.dirname(thefile)) csvfile = os.path.basename(thefile)
import sys import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import DialogResult, OpenFileDialog dialog = OpenFileDialog() dialog.Filter = "text files (*.txt)|*.txt" if dialog.ShowDialog() == DialogResult.OK: txt_path = dialog.FileName AddWarningMessage(txt_path) else: sys.exit()
Path=file_path, CaseName=self.case.CaseName, AllowMismatchingPatientID=True) self.patient.Save() fid = open(os.path.join(file_path, 'imported.txt'), 'w+') fid.close() os.remove(os.path.join(file_path, 'running.txt')) return None def main(): xxx = 1 if __name__ == "__main__": dialog = OpenFileDialog() dialog.Filter = "All Files|*.*" CT_Path_File = [] RT_Path_File = [] result = dialog.ShowDialog() Path_File = '' if result == DialogResult.OK: Path_File = dialog.FileName import_class = import_dicom_class() try: import numpy as np except: print('Running in 8') import_class = import_dicom_class_8B() if Path_File: fid = open(Path_File)