示例#1
0
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 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
示例#3
0
 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
示例#4
0
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)
示例#5
0
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"
示例#6
0
 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
示例#7
0
    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 _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)
示例#9
0
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"
示例#10
0
文件: script.py 项目: Melca-G/Aeolus
    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 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
示例#12
0
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 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
示例#14
0
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
示例#15
0
    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 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 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 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)
示例#19
0
    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
示例#20
0
文件: plotcsv.py 项目: Imme1992/wflow
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
示例#21
0
文件: Test01.py 项目: tornado80/Pack
    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()                
示例#22
0
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
示例#23
0
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
示例#24
0
 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
示例#25
0
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)

print casename

runs = getrunids(casename)

print runs
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)
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()
示例#28
0
                        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)
        CT_file_paths = fid.readline()
示例#29
0
import os, sys, re, clr
import math, cmath
import collections

win64_dir = oDesktop.GetExeDir()
dll_dir = os.path.join(win64_dir, 'common/IronPython/DLLs')
python3_dir = os.path.join(win64_dir,
                           'commonfiles/CPython/3_7/winx64/Release/python')

sys.path.append(dll_dir)
sys.path.append(python3_dir)
clr.AddReference('IronPython.Wpf')

os.chdir(os.path.dirname(__file__))

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import DialogResult, OpenFileDialog
dialog = OpenFileDialog()
dialog.Filter = "text files (*.snp)|*.s*p"

if dialog.ShowDialog() == DialogResult.OK:
    with open('plotIL.bat', 'w') as f:
        f.writelines('"{}/python" ./plotIL3.py "{}"\n'.format(
            python3_dir, dialog.FileName))

    os.system('.\plotIL.bat')
else:
    pass
示例#30
0
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))
示例#31
0
文件: tst.py 项目: Imme1992/wflow
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)

print casename

runs = getrunids(casename)

print runs