示例#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
示例#2
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)
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
示例#4
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"
示例#5
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)
示例#7
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"
示例#8
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
示例#9
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
示例#10
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"
示例#11
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
示例#14
0
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}")
示例#15
0
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
示例#16
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
示例#17
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
示例#18
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
示例#19
0
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()
示例#20
0
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
示例#21
0
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

complot(runs, csvfile, [2])
示例#22
0
                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()
        RT_file_paths = fid.readline()
        fid.close()
        CT_file_paths = CT_file_paths.split(',')[:-1]
示例#23
0
 def openfile(self, sender, event):
     ofd = OpenFileDialog()
     dr = ofd.ShowDialog()
     if dr == DialogResult.OK:
         sender.Text = ofd.FileName
示例#24
0
文件: tst.py 项目: upnigs-egl/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

complot(runs, csvfile, [2])
示例#25
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))