Beispiel #1
0
def OpenAnnotationFiles(multiple=True):
    """
    Return a list of annotation file names.
    """
    wildcard  = create_wildcard("All files", sppas.src.annotationdata.aio.extensionsul)
    wildcard += '|'+create_wildcard("SPPAS", sppas.src.annotationdata.aio.ext_sppas)
    wildcard += '|'+create_wildcard("Praat", sppas.src.annotationdata.aio.ext_praat)
    wildcard += '|'+create_wildcard("ELAN",  sppas.src.annotationdata.aio.ext_elan)
    wildcard += '|'+create_wildcard("Transcriber", sppas.src.annotationdata.aio.ext_transcriber)
    wildcard += '|'+create_wildcard("Phonedit", sppas.src.annotationdata.aio.ext_phonedit)
    wildcard += '|'+create_wildcard("ASCII", sppas.src.annotationdata.aio.ext_ascii)

    files = []
    if multiple is True:
        dlg = wx.FileDialog(None, "Select annotation file(s)", os.getcwd(), "", wildcard, wx.FD_OPEN | wx.MULTIPLE | wx.FD_CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            files = dlg.GetPaths()

    else:
        dlg = wx.FileDialog(None, "Select annotation file", sppas.SAMPLES_PATH, "", wildcard, wx.FD_OPEN | wx.FD_CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            files.append(dlg.GetPath())

    dlg.Destroy()

    if multiple is False:
        return files[0]
    return files
def OpenSoundFiles():
    """Return a list of sound file names."""

    wildcard = create_wildcard("Sound files", sppas.src.audiodata.aio.extensionsul)
    wildcard += '|' + create_wildcard("All files", ['*', '*.*'])

    files = list()
    dlg = wx.FileDialog(None, 
                        "Select sound file(s)", 
                        paths.samples, 
                        "", 
                        wildcard, 
                        wx.FD_OPEN | wx.MULTIPLE | wx.FD_CHANGE_DIR)
    if dlg.ShowModal() == wx.ID_OK:
        files = dlg.GetPaths()

    dlg.Destroy()

    return files
Beispiel #3
0
def OpenSpecificFiles(name, extensions):
    """
    Return a list of file names with specific extensions.
    """
    wildcard = create_wildcard(name, extensions)

    afile = ""
    dlg = wx.FileDialog(None, "Select a file", os.getcwd(), "", wildcard, wx.FD_OPEN | wx.FD_CHANGE_DIR)
    if dlg.ShowModal() == wx.ID_OK:
        afile = dlg.GetPath()

    dlg.Destroy()
    return afile
Beispiel #4
0
def OpenAnyFiles():
    """
    Return a list of file names.
    """
    wildcard  = create_wildcard("All files", ['*', '*.*'])

    files = []
    dlg = wx.FileDialog(None, "Select file(s)", sppas.SAMPLES_PATH, "", wildcard, wx.FD_OPEN | wx.MULTIPLE | wx.FD_CHANGE_DIR)
    if dlg.ShowModal() == wx.ID_OK:
        files = dlg.GetPaths()

    dlg.Destroy()
    return files
Beispiel #5
0
    def __on_text_filename(self, event):

        wildcard = create_wildcard("All files", ['*', '*.*'])
        dlg = wx.FileDialog(None, "Select a file", os.getcwd(), "", wildcard,
                            wx.FD_OPEN | wx.FD_CHANGE_DIR)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetPath()
            btn_obj = event.GetEventObject()
            obj = self.file_buttons[btn_obj]
            obj.SetValue(filename)
            obj.SetFocus()
            obj.Refresh()

        dlg.Destroy()
def SaveAsImageFile(preferences, image):
    """Save the current image as a PNG picture."""

    extension_map = {"png": wx.BITMAP_TYPE_PNG}
    extensions = extension_map.keys()
    wildcard = create_wildcard("Image files", extensions)

    dialog = wx.FileDialog(None, message="Export to Image",
                           wildcard=wildcard, style=wx.FD_SAVE)

    saved = False
    if dialog.ShowModal() == wx.ID_OK:
        path, extension = extend_path(dialog.GetPath(), extensions, "png")
        overwrite_question = "File '{:s}' exists. Overwrite?".format(path)

        if not os.path.exists(path) or ShowYesNoQuestion(dialog, preferences, overwrite_question) == wx.YES:
            image.SaveFile(path, extension_map[extension])
            saved = True

    dialog.Destroy()
    return saved