Python wx.FD_OPEN Examples

The following are 30 code examples of wx.FD_OPEN(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: MainUI.py    From Model-Playgrounds with MIT License 6 votes vote down vote up
def launchFileDialog(self, evt):
        # defining wildcard for suppported picture formats
        wildcard = "JPEG (*.jpg)|*.jpg|" \
                   "PNG (*.png)|*.png|" \
                   "GIF (*.gif)|*.gif"
        # defining the dialog object
        dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="",
                               wildcard=wildcard,
                               style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW)
        # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog)
        if dialog.ShowModal() == wx.ID_OK:
            self.magic_collection[1].SetValue(
                "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....")
            paths = dialog.GetPaths()

            # This adds the selected picture to the Right region. Right region object is retrieved from UI object array
            modification_bitmap1 = wx.Bitmap(paths[0])
            modification_image1 = modification_bitmap1.ConvertToImage()
            modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH)
            modification_bitmap2 = modification_image1.ConvertToBitmap()
            report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20))

            self.processPicture(paths[0],
                                "PROGRAM_INSTALL_FULLPATH\\DenseNet-BC-121-32.h5",
                                "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json") 
Example #2
Source File: archiveplayer.py    From webarchiveplayer with GNU General Public License v3.0 6 votes vote down vote up
def select_file(self):
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
        #dialog = wx.DirDialog(top, 'Please select a directory containing archive files (WARC or ARC)', style=style)
        dialog = wx.FileDialog(parent=self,
                               message='Please select a web archive (WARC or ARC) file',
                               wildcard='WARC or ARC (*.gz; *.warc; *.arc)|*.gz;*.warc;*.arc',
                               #wildcard='WARC or ARC (*.gz; *.warc; *.arc)|*.gz; *.warc; *.arc',
                               style=style)

        if dialog.ShowModal() == wx.ID_OK:
            paths = dialog.GetPaths()
        else:
            paths = None

        dialog.Destroy()
        return paths


#================================================================= 
Example #3
Source File: main.py    From wxGlade with MIT License 6 votes vote down vote up
def import_xrc(self, infilename=None, ask_save=True):
        import xrc2wxg

        if ask_save and not self.ask_save():
            return

        if not infilename:
            infilename = wx.FileSelector( _("Import file"), wildcard="XRC files (*.xrc)" "|*.xrc|All files|*",
                                          flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_path=self.cur_dir)
        if infilename:
            ibuffer = []
            try:
                xrc2wxg.convert(infilename, ibuffer)

                # Convert UTF-8 returned by xrc2wxg.convert() to Unicode
                tmp = b"".join(ibuffer).decode('UTF-8')
                ibuffer = ['%s\n'%line for line in tmp.split('\n')]

                self._open_app(ibuffer)
                common.root.saved = False
            except Exception as inst:
                fn = os.path.basename(infilename).encode('ascii', 'replace')
                bugdialog.Show(_('Import File "%s"') % fn, inst) 
Example #4
Source File: bomsaway.py    From Boms-Away with GNU General Public License v3.0 6 votes vote down vote up
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()) 
Example #5
Source File: gui.py    From RF-Monitor with GNU General Public License v2.0 6 votes vote down vote up
def __on_open(self, _event):
        if not self.__save_warning():
            return

        defDir, defFile = '', ''
        if self._filename is not None:
            defDir, defFile = os.path.split(self._filename)
        dlg = wx.FileDialog(self,
                            'Open File',
                            defDir, defFile,
                            'rfmon files (*.rfmon)|*.rfmon',
                            wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        if dlg.ShowModal() == wx.ID_CANCEL:
            return

        self.open(dlg.GetPath())

        self._isSaved = True
        self.__set_title() 
Example #6
Source File: toolbar.py    From wxGlade with MIT License 6 votes vote down vote up
def _select_bitmap(self, event, colname, title):
        control = getattr(self, colname)
        current = control.GetValue()
        directory = os.path.split(current)
        if os.path.isdir(current):
            directory = current
            current = ''
        elif directory and os.path.isdir(directory[0]):
            current = directory[1]
            directory = directory [0]
        elif common.root.filename:
            #directory = self.startDirectory
            directory = common.root.filename
            current = ""
        else:
            directory = ""
        value = misc.RelativeFileSelector(title, directory, current, wildcard="*.*", flags=wx.FD_OPEN)
        if value:
            control.SetValue(value) 
Example #7
Source File: wxgui.py    From pyshortcuts with MIT License 6 votes vote down vote up
def onBrowseScript(self, event=None):
        wildcards = "%s|%s" % (PY_FILES, ALL_FILES)

        dlg = wx.FileDialog(self, message='Select Python Script file',
                            wildcard=wildcards,
                            style=wx.FD_OPEN)

        if dlg.ShowModal() == wx.ID_OK:
            path = os.path.abspath(dlg.GetPath())
            self.txt_script.SetValue(path)

            _, name = os.path.split(path)
            name = fix_filename(name)
            if name.endswith('.py'):
                name = name[:-3]

            txt_name = self.txt_name.GetValue().strip()
            if len(txt_name) < 1:
                self.txt_name.SetValue(name)

            txt_desc = self.txt_desc.GetValue().strip()
            if len(txt_desc) < 1:
                self.txt_desc.SetValue(name)
        dlg.Destroy() 
Example #8
Source File: configuration_dialogs.py    From superpaper with MIT License 6 votes vote down vote up
def onChooseTestImage(self, event):
        """Open a file dialog to choose a test image."""
        with wx.FileDialog(self, "Choose a test image",
                           wildcard=("Image files (*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.webp)"
                                     "|*.jpg;*.jpeg;*.png;*.bmp;*.gif;*.tiff;*.webp"),
                           defaultDir=self.frame.defdir,
                           style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as file_dialog:

            if file_dialog.ShowModal() == wx.ID_CANCEL:
                return     # the user changed their mind

            # Proceed loading the file chosen by the user
            self.test_image = file_dialog.GetPath()
            self.tc_testimage.SetValue(
                os.path.basename(self.test_image)
            )
        return 
Example #9
Source File: ImagePicker.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def OnButton(self, event):
        dialog = wx.FileDialog(
            self.GetParent(),
            message=self.mesg,
            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
            wildcard=(
                "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|"
                "PNG files (*.png)|*.png"
            )
        )
        if dialog.ShowModal() == wx.ID_OK:
            filePath = dialog.GetPath()
            infile = open(filePath, "rb")
            stream = infile.read()
            infile.close()
            self.SetValue(b64encode(stream))
            event.Skip() 
Example #10
Source File: MainUI.py    From Model-Playgrounds with MIT License 6 votes vote down vote up
def launchFileDialog(self, evt):
        # defining wildcard for suppported picture formats
        wildcard = "JPEG (*.jpg)|*.jpg|" \
                   "PNG (*.png)|*.png|" \
                   "GIF (*.gif)|*.gif"
        # defining the dialog object
        dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="",
                               wildcard=wildcard,
                               style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW)
        # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog)
        if dialog.ShowModal() == wx.ID_OK:
            self.magic_collection[1].SetValue(
                "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....")
            paths = dialog.GetPaths()

            # This adds the selected picture to the Right region. Right region object is retrieved from UI object array
            modification_bitmap1 = wx.Bitmap(paths[0])
            modification_image1 = modification_bitmap1.ConvertToImage()
            modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH)
            modification_bitmap2 = modification_image1.ConvertToBitmap()
            report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20))

            self.processPicture(paths[0],
                                "PROGRAM_INSTALL_FULLPATH\\inception_v3_weights_tf_dim_ordering_tf_kernels.h5",
                                "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json") 
Example #11
Source File: MainUI.py    From Model-Playgrounds with MIT License 6 votes vote down vote up
def launchFileDialog(self, evt):
        # defining wildcard for suppported picture formats
        wildcard = "JPEG (*.jpg)|*.jpg|" \
                   "PNG (*.png)|*.png|" \
                   "GIF (*.gif)|*.gif"
        # defining the dialog object
        dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="",
                               wildcard=wildcard,
                               style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW)
        # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog)
        if dialog.ShowModal() == wx.ID_OK:
            self.magic_collection[1].SetValue(
                "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....")
            paths = dialog.GetPaths()

            # This adds the selected picture to the Right region. Right region object is retrieved from UI object array
            modification_bitmap1 = wx.Bitmap(paths[0])
            modification_image1 = modification_bitmap1.ConvertToImage()
            modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH)
            modification_bitmap2 = modification_image1.ConvertToBitmap()
            report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20))

            self.processPicture(paths[0],
                                "PROGRAM_INSTALL_FULLPATH\\squeezenet_weights_tf_dim_ordering_tf_kernels.h5",
                                "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json") 
Example #12
Source File: MainUI.py    From Model-Playgrounds with MIT License 6 votes vote down vote up
def launchFileDialog(self, evt):
        # defining wildcard for suppported picture formats
        wildcard = "JPEG (*.jpg)|*.jpg|" \
                   "PNG (*.png)|*.png|" \
                   "GIF (*.gif)|*.gif"
        # defining the dialog object
        dialog = wx.FileDialog(self, message="Select Picture", defaultDir=os.getcwd(), defaultFile="",
                               wildcard=wildcard,
                               style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW)
        # Function to retrieve file dialog response and return the full path of the first image (it is a multi-file selection dialog)
        if dialog.ShowModal() == wx.ID_OK:
            self.magic_collection[1].SetValue(
                "You have selected a Picture. It will now be processed!, Please wait! \nLoading.....")
            paths = dialog.GetPaths()

            # This adds the selected picture to the Right region. Right region object is retrieved from UI object array
            modification_bitmap1 = wx.Bitmap(paths[0])
            modification_image1 = modification_bitmap1.ConvertToImage()
            modification_image1 = modification_image1.Scale(650, 490, wx.IMAGE_QUALITY_HIGH)
            modification_bitmap2 = modification_image1.ConvertToBitmap()
            report_bitmap = wx.StaticBitmap(self.magic_collection[0], -1, modification_bitmap2, (0, 20))

            self.processPicture(paths[0],
                                "PROGRAM_INSTALL_FULLPATH\\resnet50_weights_tf_dim_ordering_tf_kernels.h5",
                                "PROGRAM_INSTALL_FULLPATH\\imagenet_class_index.json") 
Example #13
Source File: pyResManDialog.py    From pyResMan with GNU General Public License v2.0 6 votes vote down vote up
def _buttonLoadCardDataOnButtonClick(self, event):
        # Open file dialog;
        saveFileDialog = wx.FileDialog(self, "Load data from file ...", "", "", "All files (*.*)|*.*", wx.FD_OPEN)
        if saveFileDialog.ShowModal() == wx.ID_CANCEL:
            return
        file_path_name = saveFileDialog.GetPath()
        
        # Read card data from file;
        with open(file_path_name, 'rb') as f:
            card_data = f.read()
        if len(card_data) != 1024:
            self._Log('Invalid card data.', wx.LOG_Error)
            return
        
        # Set card data to Grid;
        for row_index in range(self._gridCardData.GetNumberRows()):
            for col_index in range(self._gridCardData.GetNumberCols()):
                self._gridCardData.SetCellValue(row_index, col_index, '%02X' % (ord(card_data[row_index * 0x10 + col_index])))
        self._Log('Card data has been loaded from file: %s.' % (file_path_name), wx.LOG_Info)
        return 
Example #14
Source File: LapGUI.py    From laplacian-meshes with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #15
Source File: toolbox.py    From goreviewpartner with GNU General Public License v3.0 5 votes vote down vote up
def open_all_file(parent,config,filetype):
		initialdir = grp_config.get(config[0],config[1])
		dialog = wx.FileDialog(None,_('Select a file'), defaultDir=initialdir, wildcard=filetype, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
		filename = None
		if dialog.ShowModal() == wx.ID_OK:
			filename = dialog.GetPath()
		dialog.Destroy()
		if filename:
			initialdir=os.path.dirname(filename)
			grp_config.set(config[0],config[1],initialdir)
		return filename 
Example #16
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def OnButton(self, event):
        dialog = wx.FileDialog(
            self.GetParent(),
            #message=self.mesg,
            style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST,
            wildcard="All image files|*jpg;*.png;*.bmp;*.gif|All files|*.*"
        )
        if dialog.ShowModal() == wx.ID_OK:
            filePath = dialog.GetPath()
            imageFile = open(filePath, "rb")
            stream = imageFile.read()
            imageFile.close()
            self.SetValue(b64encode(stream))
            event.Skip() 
Example #17
Source File: explorer.py    From ImageAnalysis with MIT License 5 votes vote down vote up
def get_path(wildcard):
        app = wx.App(None)
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        dialog = wx.FileDialog(None, 'Open', wildcard=wildcard, style=style)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
        else:
            path = None
        dialog.Destroy()
        return path 
Example #18
Source File: IDBrowser.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnImportButton(self, evt):
        dialog = wx.FileDialog(self, _("Choose a file"),
                               wildcard=_("PSK ZIP files (*.zip)|*.zip"),
                               style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        if dialog.ShowModal() == wx.ID_OK:
            self.model.Import(dialog.GetPath(),
                              self.ShouldIReplaceCallback) 
Example #19
Source File: wxgui.py    From pyshortcuts with MIT License 5 votes vote down vote up
def onBrowseIcon(self, event=None):

        wildcards = "%s|%s" % (ICO_FILES, ALL_FILES)
        if platform.startswith('darwin'):
            wildcards = "%s|%s" % (ICNS_FILES, ALL_FILES)

        dlg = wx.FileDialog(self, message='Select Icon file',
                            wildcard=wildcards,
                            style=wx.FD_OPEN)

        if dlg.ShowModal() == wx.ID_OK:
            path = os.path.abspath(dlg.GetPath())
            self.txt_icon.SetValue(path)
        dlg.Destroy() 
Example #20
Source File: make_timelapse.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
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)) 
Example #21
Source File: make_timelapse.py    From Pigrow with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #22
Source File: new_properties.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, value="", name=None, min_version=None):
        self._size = self._warning = self._error = None
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        self.min_version = min_version
        FileNameProperty.__init__(self, value, style, '', name) 
Example #23
Source File: new_properties.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, value="", name=None, min_version=None):
        self._size = self._warning = self._error = None
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        FileNameProperty.__init__(self, value, style, "", name)
        self.min_version = min_version 
Example #24
Source File: relay_board_gui.py    From R421A08-rs485-8ch-relay-board with MIT License 5 votes vote down vote up
def OnOpenClick(self, event=None):
        if self.ask_save_changes() == wx.ID_CANCEL:
            return

        dlg = wx.FileDialog(self, 'Load settings...', os.getcwd(), '', '*.relay', style=wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.disconnect()
            while self.m_notebook.GetPageCount():
                self.m_notebook.RemovePage(0)
            self.m_settings_file = dlg.GetPath()
            self.load_settings(self.m_settings_file)
        dlg.Destroy() 
Example #25
Source File: rstbx_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnLoadFile(self, event):
        wildcard_str = ""
        if wx.PlatformInfo[4] != "wxOSX-cocoa":
            from iotbx import file_reader

            wildcard_str = file_reader.get_wildcard_string("img")
        file_name = wx.FileSelector(
            "Image file",
            wildcard=wildcard_str,
            default_path="",
            flags=(wx.OPEN if WX3 else wx.FD_OPEN),
        )
        if file_name != "":
            self.load_image(file_name) 
Example #26
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def open_app(self, event=None):
        """loads a wxGlade project from an xml file
        NOTE: this is very slow and needs optimisation efforts
        NOTE2: the note above should not be True anymore :) """
        if not self.ask_save():
            return
        default_path = os.path.dirname(common.root.filename or "") or self.cur_dir
        infile = wx.FileSelector(_("Open file"),
                                   wildcard="wxGlade files (*.wxg)|*.wxg|wxGlade Template files (*.wgt)|*.wgt|"
                                            "XML files (*.xml)|*.xml|All files|*",
                                   flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, default_path=default_path)
        if not infile: return
        self._open(infile) 
Example #27
Source File: rstbx_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnLoadLabelitResult(self, event):
        file_name = wx.FileSelector(
            "Labelit result", default_path="", flags=(wx.OPEN if WX3 else wx.FD_OPEN)
        )
        if file_name != "":
            self.load_image(file_name) 
Example #28
Source File: GoSyncModel.py    From gosync with GNU General Public License v2.0 5 votes vote down vote up
def getCredentialFile(self):
        # ask for the Credential file and save it in Config directory then return True
        defDir, defFile = '', ''
        dlg = wx.FileDialog(None,
               'Load Credential File',
                 '~', 'Credentials.json',
                 'json files (*.json)|*.json',
                 wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        if dlg.ShowModal() == wx.ID_CANCEL:
            return False
        try:
            shutil.copy(dlg.GetPath(), self.credential_file)
            return True
        except:
            return False 
Example #29
Source File: wx_ctrl_phoenix.py    From pybass with Apache License 2.0 5 votes vote down vote up
def method_load_file(self):
		import os
		wildcard = 'music sounds (MO3, IT, XM, S3M, MTM, MOD, UMX)|*.mo3;*.it;*.xm;*.s3m;*.mtm;*.mod;*.umx'
		wildcard += '|stream sounds (MP3, MP2, MP1, OGG, WAV, AIFF)|*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aiff'
		for plugin in self.plugins.itervalues():
			if plugin[0] > 0:
				wildcard += plugin[1]
		wildcard += '|All files (*.*)|*.*'
		dlg = wx.FileDialog(self, message = _('Choose a file'), defaultDir = os.getcwd(),  defaultFile = '', wildcard = wildcard, style = wx.FD_OPEN|wx.FD_CHANGE_DIR)
		if dlg.ShowModal() == wx.ID_OK:
			self.name_stream = file_name = dlg.GetPath()
			if os.path.isfile(file_name):
				flags = 0
				if isinstance(file_name, unicode):
					flags |= pybass.BASS_UNICODE
					try:
						pybass.BASS_CHANNELINFO._fields_.remove(('filename', pybass.ctypes.c_char_p))
					except:
						pass
					else:
						pybass.BASS_CHANNELINFO._fields_.append(('filename', pybass.ctypes.c_wchar_p))
				error_msg = 'BASS_StreamCreateFile error %s'
				new_bass_handle = 0
				if dlg.GetFilterIndex() == 0:#BASS_CTYPE_MUSIC_MOD
					flags |= pybass.BASS_MUSIC_PRESCAN
					new_bass_handle = pybass.BASS_MusicLoad(False, file_name, 0, 0, flags, 0)
					error_msg = 'BASS_MusicLoad error %s'
				else:#other sound types
					new_bass_handle = pybass.BASS_StreamCreateFile(False, file_name, 0, 0, flags)
				if new_bass_handle == 0:
					print(error_msg % pybass.get_error_description(pybass.BASS_ErrorGetCode()))
				else:
					self.method_stop_audio()
					self.bass_handle = new_bass_handle
					self.stream = None
					self.method_slider_set_range()
					self.method_check_controls() 
Example #30
Source File: native_file_chooser.py    From kivy-smoothie-host with GNU General Public License v3.0 5 votes vote down vote up
def _wx_get_path(self):
        app = wx.App(None)
        style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
        dialog = wx.FileDialog(None, self.title, defaultDir=self.start_dir, wildcard='GCode files|*.g;*.gcode;*.nc;*.gc;*.ngc|All Files|*', style=style)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
        else:
            path = None
        dialog.Destroy()
        return path