Python wx 模块,FD_OPEN 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用wx.FD_OPEN

项目:mobileinsight-core    作者:mobile-insight    | 项目源码 | 文件源码
def Open(self, e):
        openFileDialog = wx.FileDialog(
            self,
            "Open Log file",
            "",
            "",
            "log files (*.mi2log) |*.mi2log| All files |*.*",
            wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
        if (openFileDialog.ShowModal() == wx.ID_OK):
            # print 'Selected %s' %openFileDialog.GetPath()
            print 'Selected %s' % openFileDialog.Paths
            try:
                self.grid.ClearGrid()

                # thread.start_new_thread(openFile,(openFileDialog.GetPath(),))
                # t = Thread(target = self.openFile, args=(openFileDialog.GetPath(),self.selectedTypes))
                t = Thread(
                    target=self.openFile,
                    args=(
                        openFileDialog.Paths,
                        self.selectedTypes))
                self.progressDialog = ProgressDialog(self)
                t.start()
                self.progressDialog.ShowModal()

                if len(openFileDialog.Paths) == 1:
                    self.SetTitle(openFileDialog.GetPath())
                else:
                    self.SetTitle(
                        "Multiple files in " +
                        openFileDialog.Directory)

            except e:
                print "Error while opening file.", e
            # if (random() > 0.5):
            #    self.SetupGrid(self.data1)
            # else:
            #    self.SetupGrid(self.data2)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def loadFile(self, event=None):
        openFileDialog = wx.FileDialog(None, message='Load EEG data.',
            wildcard='JSON (*.json)|*.json|All Files|*',
            style=wx.FD_OPEN)

        try:
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return wx.ID_CANCEL
        except Exception:
            wx.LogError('Save failed!')
            raise
        finally:
            openFileDialog.Destroy()

        cap = eeg.EEGFromJSON(openFileDialog.GetPath(), protocol='3minutes')
        self.replayData = cap.data

        self.setSampRate(cap.getSampRate())
        self.setChans(cap.getChanNames())
项目:laplacian-meshes    作者:bmershon    | 项目源码 | 文件源码
def OnLoadMesh(self, evt):
        dlg = wx.FileDialog(self, "Choose a file", ".", "", "OFF files (*.off)|*.off|TOFF files (*.toff)|*.toff|OBJ files (*.obj)|*.obj", wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            dirname = dlg.GetDirectory()
            filepath = os.path.join(dirname, filename)
            print dirname
            self.glcanvas.mesh = PolyMesh()
            print "Loading mesh %s..."%filename
            self.glcanvas.mesh.loadFile(filepath)
            self.glcanvas.meshCentroid = self.glcanvas.mesh.getCentroid()
            self.glcanvas.meshPrincipalAxes = self.glcanvas.mesh.getPrincipalAxes()
            print "Finished loading mesh"
            print self.glcanvas.mesh
            self.glcanvas.initMeshBBox()
            self.glcanvas.clearAllSelections()
            self.glcanvas.Refresh()
        dlg.Destroy()
        return
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def getpath(title, filt, k, para=None):
    """Get the defaultpath of the ImagePy"""
    dpath = manager.ConfigManager.get('defaultpath')
    if dpath ==None:
        dpath = root_dir # './'
    dic = {'open':wx.FD_OPEN, 'save':wx.FD_SAVE}
    dialog = wx.FileDialog(curapp, title, dpath, '', filt, dic[k])
    rst = dialog.ShowModal()
    path = None
    if rst == wx.ID_OK:
        path = dialog.GetPath()
        dpath = os.path.split(path)[0]
        manager.ConfigManager.set('defaultpath', dpath)
        if para!=None:para['path'] = path
    dialog.Destroy()

    return rst if para!=None else path
项目:Boms-Away    作者:Jeff-Ciesielski    | 项目源码 | 文件源码
def on_open(self, event):
        """
        Recursively loads a KiCad schematic and all subsheets
        """
        #self.save_component_type_changes()
        open_dialog = wx.FileDialog(self, "Open KiCad Schematic", "", "",
                                         "Kicad Schematics (*.sch)|*.sch",
                                         wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

        if open_dialog.ShowModal() == wx.ID_CANCEL:
            return

        # Load Chosen Schematic
        print("opening File:", open_dialog.GetPath())

        # Store the path to the file history
        self.filehistory.AddFileToHistory(open_dialog.GetPath())
        self.filehistory.Save(self.config)
        self.config.Flush()

        self.load(open_dialog.GetPath())
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_open(*args, **kwargs):
    wildcard = "Arquivo de projeto do GRIPy (*.pgg)|*.pgg"
    try:
        fdlg = wx.FileDialog(wx.App.Get().GetTopWindow(), 
                             'Escolha o arquivo PGG', 
                             wildcard=wildcard, 
                             style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST
        )
        if fdlg.ShowModal() == wx.ID_OK:
            file_name = fdlg.GetFilename()
            dir_name = fdlg.GetDirectory()
            fdlg.Destroy()
        else:
            fdlg.Destroy()
            return
        fullfilename = os.path.join(dir_name, file_name)    
        gripy_app = wx.App.Get()
        gripy_app.load_project_data(fullfilename)
    except Exception:
        raise
项目:i3ColourChanger    作者:PMunch    | 项目源码 | 文件源码
def OnOpen(self, event):
        openFileDialog = wx.FileDialog(self, "Open i3 Config file", os.path.expanduser("~/.i3/"), "","i3 Config file |*", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        if openFileDialog.ShowModal() == wx.ID_CANCEL:
            return
        cfg = Config(self.messager,openFileDialog.GetPath())
        self.LoadConfig(cfg)
项目:nimo    作者:wolfram2012    | 项目源码 | 文件源码
def onOpen(self,event):
        print "Open"
        fd = wx.FileDialog(self,style=wx.FD_OPEN)
        fd.ShowModal()
        self.filename = fd.GetPath()
        print "On Open...",self.filename

        self.openCSVFile(self.filename)
项目:stopgo    作者:notklaatu    | 项目源码 | 文件源码
def Ingest(self):
    openMsg='Choose a image directory'
    wcd = 'All files (*)|*|Image Directory (*)|*'
    dirname = os.path.join(os.path.expanduser('~'),self.myprefs['dir'])

    od = wx.DirDialog(self, message=openMsg,
                      style=wx.FD_OPEN|wx.FD_CHANGE_DIR)

    if od.ShowModal() == wx.ID_OK:
        projpath= os.path.join( od.GetPath() )
        print(projpath)
        dbfile = os.path.join ( os.path.dirname(projpath), os.path.basename( od.GetPath())) + '_import_' + str(time.time()).split('.')[0]
        self.imgdir = projpath

        #with open(os.path.join(projpath,dbfile), 'a'):
        #    os.utime(path, None)
        open( dbfile, 'a' ).close()

        self.con = sq.connect(dbfile, isolation_level=None )

        self.cur = self.con.cursor()
        self.cur.execute("CREATE TABLE IF NOT EXISTS Project(Id INTEGER PRIMARY KEY, Path TEXT, Name TEXT, [timestamp] timestamp)")
        self.cur.execute("CREATE TABLE IF NOT EXISTS Timeline(Id INTEGER PRIMARY KEY, Image TEXT, Blackspot INT)")
        self.cur.execute("INSERT INTO Project(Path, Name, timestamp) VALUES (?,?,?)", ("images", "StopGo Project", datetime.now() ))

        for counter, item in enumerate( sorted(os.listdir(self.imgdir)) ):
            self.cur.execute("INSERT INTO Project(Path, Name, timestamp) VALUES (?,?,?)", ("images", "Default Project", datetime.now() ))
            self.cur.execute("INSERT INTO Project(Path, Name, timestamp) VALUES (?,?,?)", ("images", "Default Project", datetime.now() ))
            self.cur.execute('INSERT INTO Timeline VALUES(?,?,?)', (counter,item,0))

        self.BuildTimeline(dbfile)
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
def audio_btn_click(self, e):
        openFileDialog = wx.FileDialog(self, "Select caps folder", "", "", "MP3 files (*.mp3)|*.mp3", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        openFileDialog.SetMessage("Select an audio file from to use")
        if openFileDialog.ShowModal() == wx.ID_CANCEL:
            return 'none'
        audio_track = openFileDialog.GetPath()
        self.audio_box.SetValue(str(audio_track))
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
def select_caps_folder(self):
        openFileDialog = wx.FileDialog(self, "Select caps folder", "", "", "JPG files (*.jpg)|*.jpg", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        openFileDialog.SetMessage("Select an image from the caps folder you want to import")
        if openFileDialog.ShowModal() == wx.ID_CANCEL:
            return 'none'
        new_cap_path = openFileDialog.GetPath()

        capsdir = os.path.split(new_cap_path)
        capset   = capsdir[1].split(".")[0][0:-10]  # Used to select set if more than one are present
        cap_type = capsdir[1].split('.')[1]
        capsdir = capsdir[0] + '/'
        print(" Selected " + capsdir + " with capset; " + capset + " filetype; " + cap_type)
        return capsdir, capset, cap_type
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent, name, objectpath, textwidth, file_extension):
        def assign(input):
            self.objectpath.ChangeValue(input)
        def OnBrowse(self):
            if IsNotWX4():
                dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '',  file_extension, wx.OPEN)
            else:
                dlg = wx.FileDialog(parent, 'Choose a file', os.getcwd(), '',  file_extension, wx.FD_OPEN)
            if dlg.ShowModal() == wx.ID_OK:
                assign(dlg.GetPath())
            dlg.Destroy()
        def OnEdit(event):
            self.objectpath.ChangeValue(event.GetString())
        fontpointsize=wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPointSize()
        self.font = wx.Font(fontpointsize, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
        dc = wx.ScreenDC()
        dc.SetFont(self.font)
        textw,texth = dc.GetTextExtent(name)
        if textw > textwidth:
            labelw = textw
        else:
            labelw = textwidth
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        self.label = StaticTextNew(parent, -1, name, style =wx.ALIGN_RIGHT, size=(labelw,-1) )
        self.label.SetFont(self.font)
        self.Add( self.label, 0, wx.CENTER )
        self.objectpath = TextCtrlNew(parent, -1)
        self.objectpath.SetFont(self.font)
        self.objectpath.SetValue(objectpath)
        self.objectpath.SetToolTipNew("Browse for file or type "+os.linesep+"path and name")
        self.objectpath.Bind(wx.EVT_TEXT_ENTER, OnEdit)
        self.Add( self.objectpath, 1, wx.CENTER |wx.EXPAND )
        self.button = ButtonNew(parent, -1, "Browse")
        self.button.SetFont(self.font)
        self.button.SetToolTipNew("Browse for file or type "+os.linesep+"path and name")
        self.button.Bind(wx.EVT_BUTTON, OnBrowse)
        self.Add( self.button, 0, wx.LEFT|wx.CENTER)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnOpen(self,e):
        panelphase = self.GetChildren()[1].GetPage(0)
        if panelphase.pipeline_started == False:
            cwd = self.CurrentWD()
            if IsNotWX4():
                dlg = wx.FileDialog(self, "Choose a file", cwd, "", "fin files (*.fin)|*.fin|All files (*.*)|*.*", wx.OPEN)
            else:
                dlg = wx.FileDialog(self, "Choose a file", cwd, "", "fin files (*.fin)|*.fin|All files (*.*)|*.*", wx.FD_OPEN)
            if dlg.ShowModal() == wx.ID_OK:
                self.filename = dlg.GetFilename()
                self.dirname = dlg.GetDirectory()
                RestoreInstance(self)
            dlg.Destroy()
项目:magic-card-database    作者:drknotter    | 项目源码 | 文件源码
def on_open(self,e):
        """ Open a file"""
        self.dirname = ''
        dlg = wx.FileDialog(self, "Choose a deck", self.dirname, "", "*.db", wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.filename = dlg.GetFilename()
            self.dirname = dlg.GetDirectory()
            print self.dirname, self.filename
#            f = open(os.path.join(self.dirname, self.filename), 'r')
#            self.control.SetValue(f.read())
#            f.close()
        dlg.Destroy()
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
def browse(self, event):
        wildcard = "Audio and Video files ({wildcards})|{wildcards}".format(wildcards=';'.join(FILE_EXTS))
        file_dialog = wx.FileDialog(self, message="Select files",
                                    style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_FILE_MUST_EXIST, wildcard=wildcard)
        file_dialog.SetDirectory(self.in_dir) if self.in_dir else None
        if file_dialog.ShowModal() != wx.ID_OK:
            file_dialog.Destroy()
            return
        self.in_files = file_dialog.GetPaths()
        self.in_picker.GetTextCtrl().SetValue(str(file_dialog.GetFilenames()).strip('[]'))
        file_dialog.Destroy()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def on_save(self, evt):
        dic = {'open':wx.FD_OPEN, 'save':wx.FD_SAVE}
        filt = 'PNG files (*.png)|*.png'
        dialog = wx.FileDialog(self, 'Save Picture', '', '', filt, wx.FD_SAVE)
        rst = dialog.ShowModal()
        if rst == wx.ID_OK:
            path = dialog.GetPath()
            self.canvas.save_bitmap(path)
        dialog.Destroy()
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def OnOpen(self,event):
        dialog=wx.FileDialog(None,'wxpython Notebook(o)',style=wx.FD_OPEN)
        if dialog.ShowModal()==wx.ID_OK:
            self.file=dialog.GetPath()
            file=open(self.file)
            self.text.write(file.read())
            file.close()
        dialog.Destroy()
项目:bp5000    作者:isaiahr    | 项目源码 | 文件源码
def load_event(self, e):
        dia = wx.FileDialog(self, "Load Bracket",
                            "", "", "bp5000 bracket|*.bp5", wx.FD_OPEN)
        if dia.ShowModal() == wx.ID_CANCEL:
            return
        brs = bracketio.read_bracket(dia.GetPath())
        if isinstance(brs, str):
            w = wx.MessageDialog(self, brs, "Error", wx.ICON_ERROR)
            w.ShowModal()
            w.Destroy()
            return
        name = dia.GetFilename().replace(".bp5", "")
        pg = ManagementPage(self.nb, name, len(brs), brs)
        self.nb.InsertPage(0, pg, name)
项目:py3_project    作者:tjy-cool    | 项目源码 | 文件源码
def find_file(self, event):
        ''' ????????? '''
        dlg = wx.FileDialog(None, "???????",
                            os.getcwd(),
                            defaultFile="",
                            style=wx.FD_OPEN | wx.FD_MULTIPLE
                            )  # wildcard=wildcard
        info = ""
        self.totle_gauge.SetValue(0)
        if dlg.ShowModal() == wx.ID_OK:
            self.file_cnt = len(dlg.GetPaths())
            self.totle_gauge.SetRange(100 * self.file_cnt)

            tol_size = 0
            for path in dlg.GetPaths():
                tol_size += os.stat(path).st_size

            for index, path in enumerate(dlg.GetPaths()):    # ????????
                self.sigle_gauge.SetValue(0)
                if self.version_box.GetValue():
                    info += "???" + path + "\n"

                file_info = self.getfile_info(path)
                info += "???" + str(file_info[0]) + "??\n"
                if self.time_box.GetValue():
                    info += "?????" + file_info[1] + "\n"

                md5 = self.gethash_info(path, index)
                if self.md5_box.GetValue():
                    info += "MD5?" + md5[0] + "\n"
                if self.sha1_box.GetValue():
                    info += "SHA1?" + md5[1] + "\n"
                if self.crc32_box.GetValue():
                    info += "CRC32?" + md5[2] + "\n"

                info += "\n"
                # self.sigle_gauge.SetValue(100)
                # self.totle_gauge.SetValue(100 * (index + 1))

        self.t1.SetValue(info)
        # print(info)
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def file_chooser(title='Choose a file:', default_path = '', default_file = '',
                 mode='r', wildcard='*', parent_obj = None):
    """Provides a file chooser dialog and returns the file path(s) when the file(s) is selected.
    mode option provides file dialog type: read single, read multiple, or save single.
    mode = 'r' creates an 'Open' file dialog for single file read.
    mode = 'm' creates an 'Open' file dialog for multiple files read.
    mode = 'w' creates a 'Save' file dialog.

    wildcard option can be specified as "*.xls"

    Example:
    >> file_chooser(title='Choose a file:', mode='r')

    """

    wildcard = "%s|%s" % (wildcard, wildcard)

    style = { 'r': wx.FD_OPEN,
              'm': wx.FD_MULTIPLE,
              'w': wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT }[mode]

    try:
        file_chooser = wx.FileDialog(parent_obj, title, wildcard=wildcard, style=style,
                                     defaultDir = default_path, defaultFile = default_file)
    except wx._core.PyNoAppError:
        app = mzApp()
        app.launch()
        file_chooser = wx.FileDialog(parent_obj, title, wildcard=wildcard, style=style,
                                     defaultDir = default_path, defaultFile = default_file)


    file_name = None
    if file_chooser.ShowModal() == wx.ID_OK:
        if mode == 'm':
            file_name = file_chooser.GetPaths()
        else:
            file_name = file_chooser.GetPath()
    file_chooser.Destroy()

    return file_name
项目:hachoir3    作者:vstinner    | 项目源码 | 文件源码
def file_open_dialog():
    dialog_style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST

    dialog = wx.FileDialog(
        None, message='Open',
        defaultDir=os.getcwd(),
        defaultFile='', style=dialog_style)

    return dialog
项目:Janet    作者:nosmokingbandit    | 项目源码 | 文件源码
def set_cemu_exe(self):
        dialog = wx.FileDialog(None, "Open", desktop, "", "Cemu (*.exe)|*.exe", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)  # self.app.frame,

        dialog.ShowModal()
        cemu_exe = dialog.GetPath()

        if cemu_exe:
            core.CONFIG['cemu_exe'] = cemu_exe

            self.browser.ExecuteJavascript('$("input#cemu_exe").val({})'.format(json.dumps(cemu_exe)))

        dialog.Destroy()
项目:Janet    作者:nosmokingbandit    | 项目源码 | 文件源码
def set_bg_image(self):
        dialog = wx.FileDialog(None, "Open", desktop, "", "Images (*.jpg; *.png; *.bmp)|*.jpg; *.png; *.bmp", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

        dialog.ShowModal()
        bg_image = dialog.GetPath()

        print bg_image

        if bg_image:
            core.CONFIG['background_image'] = bg_image

            self.browser.ExecuteJavascript('$("input#background_image").val({})'.format(json.dumps(bg_image)))
            self.browser.ExecuteFunction('update_bg_image', json.dumps(bg_image))

        dialog.Destroy()
项目:V2R-biological-information    作者:joyce850722    | 项目源码 | 文件源码
def OpenfileButton(self, event):
        openFileDialog = wx.FileDialog(self, "Open", "", "", "Newick files (*.nwk)|*.nwk", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        openFileDialog.ShowModal()      
        self.path = openFileDialog.GetPath()

        if self.path != "":
            st = self.path.rfind("/") + 1
            self.m_staticText161.SetForegroundColour((0, 100, 0))
            self.m_staticText161.SetLabel(self.path[st :])          
            self.m_staticText16.SetLabel(u"???????")
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def onBrowse(self, event):
        """
        Browse for file
        """
        wildcard = "JPEG files (*.jpg)|*.jpg"
        dialog = wx.FileDialog(None, "Choose a file",
                               wildcard=wildcard,
                               style=wx.FD_OPEN)
        if dialog.ShowModal() == wx.ID_OK:
            self.photoTxt.SetValue(dialog.GetPath())
        dialog.Destroy()
        self.onView()
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_import_segy_seis(event):
    style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
    wildcard="Arquivos SEG-Y (*.sgy)|*.sgy"

    file_dlg = wx.FileDialog(wx.App.Get().GetTopWindow(), 
                         'Escolha o arquivo SEG-Y', 
                         wildcard=wildcard, style=style
    )
    result = file_dlg.ShowModal()
    if result == wx.ID_OK:
        file_name = file_dlg.GetFilename()
        dir_name  = file_dlg.GetDirectory()
    file_dlg.Destroy()
    if result == wx.ID_CANCEL:
        return
    name = file_name.split('.')[0]
    app_utils.load_segy(event, os.path.join(dir_name, file_name), 
                    new_obj_name=name, comparators_list=None, 
              iline_byte=9, xline_byte=21, offset_byte=37
    )
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_import_segy_vel(event):
    style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
    wildcard="SEG-Y files (*.sgy)|*.sgy"
    fdlg = wx.FileDialog(wx.App.Get().GetTopWindow(), 'Choose SEG-Y file', 
                         wildcard=wildcard, style=style)
    if fdlg.ShowModal() == wx.ID_OK:
        file_name = fdlg.GetFilename()
        dir_name  = fdlg.GetDirectory()
        fdlg.Destroy()
    else:
        fdlg.Destroy()
        return

    segy_file = FileIO.SEGY.SEGYFile(os.path.join(dir_name, file_name))
    segy_file.read()
    name = segy_file.filename.rsplit('\\')[-1]
    name = name.split('.')[0]


    OM = ObjectManager(event.GetEventObject())     
    velocity = OM.new('velocity', segy_file.data, name=name, 
                           unit='ms', domain='time', 
                           sample_rate=segy_file.sample_rate*1000, datum=0,
                           samples=segy_file.number_of_samples,
                           #stacked=stacked,
                           traces=int(segy_file.data.shape[0])
    )

    OM.add(velocity)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def onLoadFile(self, evt):
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        wildcard = "Arquivo de console GRIPy (*.gripy_console)|*.gripy_console"
        fdlg = wx.FileDialog(self, 'Escolha o arquivo gripy_console', 
                             defaultDir=self.dir_name, 
                             wildcard=wildcard, 
                             style=style
        )
        if fdlg.ShowModal() == wx.ID_OK:
            self.file_name = fdlg.GetFilename()
            self.dir_name = fdlg.GetDirectory()
            self._load_file()
        fdlg.Destroy()
项目:SpatialTool    作者:JRcard    | 项目源码 | 文件源码
def loadSnd(self,e):
        wildcard = "All files|*.*|" \
               "AIFF file|*.aif;*.aiff;*.aifc;*.AIF;*.AIFF;*.Aif;*.Aiff|" \
               "Wave file|*.wav;*.wave;*.WAV;*.WAVE;*.Wav;*.Wave"
        dlg = wx.FileDialog(self, message="Choose a new soundfile...", 
                            wildcard=wildcard, style=wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            if path != "":
                # FL 10/02/2017 START
                try:
    #                self.chooseSnd.SetLabel("Ready")
                    self.stopSnd(e)
                    self.audio.changeSnd(path)
                    self.sndDurSecs = sndinfo(path)[1] # FL 02/09/2107
                    self.chrono.SetLabel(self.secs2Time(0))
                    self.timeLeft.SetLabel("- "+ self.secs2Time(self.sndDurSecs))
                    self.sndName.SetLabel(os.path.split(path)[1])
                except:
                    self.audio.changeSnd(EMPTY_AUDIO_FILE)
                    self.chrono.SetLabel("--:--:--.--")
                    self.timeLeft.SetLabel("- --:--:--.--")
                    self.sndName.SetLabel("<WAV or AIFF soundfiles only>")
                if self.audio.noSound:
                    self.playPause.Disable()
                    self.stopBtn.Disable()
                else:
                    self.playPause.Enable()
                    self.stopBtn.Enable()
                # FL END
        dlg.Destroy()        
        self.Refresh()

    # J'ai tellement pas de mérite j'ai pris cette fonction sur Internet lol
    # FL 02/09/2017
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def report_chooser(title=None, mode='r', parent = None, **kwargs):
    '''A specialized file_chooser function for multiplierz files. Otherwise,
    works just like file_chooser.

    'parent' is the parent of the dialog--used when this is called by a GUI
    element. It is perfectly fine to leave it as None, and the GUI frame will
    have no parent.

    'title' can be left blank for the following default titles based on mode:
    r - 'Choose multiplierz File:'
    w - 'Save File:'
    m - 'Choose multiplierz Files:'

    'mode' is one of 'r', 'w', and 'm', just as for file_chooser.

    **kwargs can include any additional options to pass to the FileDialog constructor,
    such as defaultDir (default directory).'''

    # For legacy reasons, these are often misplaced in scripts.
    # But they're both necessarily typed differently, so its sortable.
    if isinstance(parent, basestring) and not isinstance(title, basestring):
        title, parent = parent, title

    wildcard = ("Worksheets (*.xls; *.xlsx)|*.xls; *.xlsx|"
                "Comma-separated Values (*.csv)|*.csv|"
                "mzResults Database (*.mzd)|*.mzd|"
                "mzIdentML (*.mzid)|*.mzid")

    if not title:
        title = {'r': 'Choose multiplierz File:',
                 'w': 'Save File:',
                 'm': 'Choose multiplierz Files:'}[mode]

    style = { 'r': wx.FD_OPEN,
              'm': wx.FD_MULTIPLE,
              'w': wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT }[mode]

    #index = {'.xls': 0,
             #'.xlsx': 0,
             #'.csv': 1,
             #'.mzd': 2}[settings.default_format]

    index = 0

    try:
        file_dialog = wx.FileDialog(parent, title, wildcard=wildcard, style=style, **kwargs)
    except wx._core.PyNoAppError as err:
        app = mzApp()
        app.launch()
        file_dialog = wx.FileDialog(None, title, wildcard=wildcard, style=style, **kwargs)
    file_dialog.SetFilterIndex(index)

    file_name = None
    if file_dialog.ShowModal() == wx.ID_OK:
        if mode == 'm':
            file_name = file_dialog.GetPaths()
        else:
            file_name = file_dialog.GetPath()
    file_dialog.Destroy()

    return file_name
项目:Migrate2WinSSHTerm    作者:P-St    | 项目源码 | 文件源码
def read_superputty_xml(self):
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        dialog = wx.FileDialog(self, message='Open Sessions.XML', wildcard='(*.XML)|*.XML', style=style)
        if dialog.ShowModal() == wx.ID_OK:
            file = dialog.GetPath()
        else:
            return False
        dialog.Destroy()
        try:
            tree = ET.parse(file)
            for item in tree.iter():
                if item.tag == "SessionData":
                    sessionPath = item.attrib.get('SessionId')
                    list = sessionPath.encode('utf-8').split('/')
                    tmp = self.root
                    res = Resolver('name')
                    counter = 1
                    for i in list:
                        pathB64 = base64.b64encode(i)
                        try:
                            if res.get(tmp, pathB64):
                                tmp = res.get(tmp, pathB64)
                                if counter >= len(list):
                                    print pathB64
                                    self.saveSessionData(
                                        node=tmp,
                                        name=str(item.attrib.get('SessionName').encode('utf-8')),
                                        username=str(item.attrib.get('Username').encode('utf-8')),
                                        privateKey='',
                                        hostname=str(item.attrib.get('Host').encode('utf-8')),
                                        port=str(item.attrib.get('Port').encode('utf-8'))
                                        )
                                    print pathB64
                        except ChildResolverError as e:
                            if counter < len(list):
                                tmp = Node(pathB64, parent=tmp, type="Container")
                            if counter >= len(list):
                                self.saveSessionData(
                                    node=tmp,
                                    name=str(item.attrib.get('SessionName').encode('utf-8')),
                                    username=str(item.attrib.get('Username').encode('utf-8')),
                                    privateKey='',
                                    hostname=str(item.attrib.get('Host').encode('utf-8')),
                                    port=str(item.attrib.get('Port').encode('utf-8'))
                                    )
                        counter = counter + 1
            return True
        except Exception as e:
            return False
项目:Migrate2WinSSHTerm    作者:P-St    | 项目源码 | 文件源码
def read_mobaxterm_ini(self):
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        dialog = wx.FileDialog(self, message='Open MobaXterm.ini', wildcard='(*.ini)|*.ini', style=style)
        if dialog.ShowModal() == wx.ID_OK:
            file = dialog.GetPath()
        else:
            return False
        dialog.Destroy()
        try:
            config = configparser.RawConfigParser()
            config.optionxform = str
            config.read(file)
            res = Resolver('name')
            for s in config.sections():
                if s.startswith('Bookmarks'):
                    if config[s]['SubRep'] == 'PuTTY sessions':
                        continue
                    tmp = self.root
                    for (key,val) in config.items(s):
                        if key == 'ImgNum':
                            continue
                        if key == 'SubRep' and val:
                            sessionPath = config[s]['SubRep']
                            list = sessionPath.encode('utf-8').split('\\')
                            counter = 1
                            for i in list:
                                pathB64 = base64.b64encode(i)
                                try:
                                    if res.get(tmp, pathB64):
                                        tmp = res.get(tmp, pathB64)
                                except ChildResolverError as e:
                                    node = Node(pathB64, parent=tmp, type='Container')
                                    tmp = node
                                counter = counter + 1
                            break
                    for (key,val) in config.items(s):
                        if key == 'ImgNum' or key == 'SubRep':
                            continue
                        sessionData = val.encode('utf-8').split('%')
                        if sessionData[0] == '#109#0':
                            self.saveSessionData(tmp, key, sessionData[3], '', sessionData[1], sessionData[2])
            return True
        except Exception as e:
            return False