Exemplo n.º 1
0
def SaveAsAudioFile(defaultdir=None,defaultfile=None):
    """
    Return an audio file name.
    """
    if defaultdir is None:
        defaultdir = os.path.dirname(sp_glob.BASE_PATH)

    if defaultfile is None:
        defaultfile = "newfile.wav"

    file = None

    wildcard  = create_wildcard("All files", audiodata.io.extensions)
    wildcard += '|'+create_wildcard("Wave", audiodata.io.ext_wav)
    wildcard += '|'+create_wildcard("Aiff", audiodata.io.ext_aiff)
    wildcard += '|'+create_wildcard("SunAu",  audiodata.io.ext_sunau)

    dlg = wx.FileDialog(
        None, message = "Choose a file name...",
        defaultDir  = defaultdir,
        defaultFile = defaultfile,
        wildcard    = wildcard,
        style = wx.FD_SAVE | wx.FD_CHANGE_DIR )

    if dlg.ShowModal() == wx.ID_OK:
        file = dlg.GetPath()

    dlg.Destroy()

    return file
Exemplo n.º 2
0
def SaveAsAnnotationFile(defaultdir=None,defaultfile=None):
    """
    Return an annotation file name.
    """
    if defaultdir is None:
        defaultdir = os.path.dirname(sp_glob.BASE_PATH)

    if defaultfile is None:
        defaultfile = "newfile.xra"

    file = None

    wildcard  = create_wildcard("All files", io.extensions_out)
    wildcard += '|'+create_wildcard("SPPAS", io.ext_sppas)
    wildcard += '|'+create_wildcard("Praat", io.ext_praat)
    wildcard += '|'+create_wildcard("ELAN",  io.ext_elan)
    wildcard += '|'+create_wildcard("Phonedit", io.ext_phonedit)
    wildcard += '|'+create_wildcard("ASCII", io.ext_ascii)
    wildcard += '|'+create_wildcard("AnnotationPro", io.ext_annotationpro)
    wildcard += '|'+create_wildcard("Subtitles", io.ext_subtitles)

    dlg = wx.FileDialog(
        None, message = "Choose a file name...",
        defaultDir = defaultdir,
        defaultFile = defaultfile,
        wildcard = wildcard,
        style = wx.FD_SAVE | wx.FD_CHANGE_DIR )

    if dlg.ShowModal() == wx.ID_OK:
        file = dlg.GetPath()

    dlg.Destroy()

    return file
Exemplo n.º 3
0
def OpenSoundFiles():
    """
    Return a list of sound file names.
    """

    wildcard  = create_wildcard("Sound files", signals.extensionsul)
    wildcard += '|'+create_wildcard("All files", ['*', '*.*'])

    files = []
    dlg = wx.FileDialog(None, "Select sound file(s)", sp_glob.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
Exemplo n.º 4
0
def OpenAnnotationFiles(multiple=True):
    """
    Return a list of annotation file names.
    """
    wildcard  = create_wildcard("All files", io.extensionsul)
    wildcard += '|'+create_wildcard("SPPAS", io.ext_sppas)
    wildcard += '|'+create_wildcard("Praat", io.ext_praat)
    wildcard += '|'+create_wildcard("ELAN",  io.ext_elan)
    wildcard += '|'+create_wildcard("Transcriber", io.ext_transcriber)
    wildcard += '|'+create_wildcard("Phonedit", io.ext_phonedit)
    wildcard += '|'+create_wildcard("ASCII", io.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", sp_glob.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
Exemplo n.º 5
0
def OpenAnyFiles():
    """
    Return a list of annotation file names.
    """
    wildcard  = create_wildcard("All files", ['*', '*.*'])

    files = []
    dlg = wx.FileDialog(None, "Select file(s)", sp_glob.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
Exemplo n.º 6
0
def SaveAsImageFile(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?" % path

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

    dialog.Destroy()
    return saved
Exemplo n.º 7
0
def SaveAsAnyFile(defaultdir=None,defaultfile=None):
    """
    """
    if defaultdir is None:
        defaultdir = os.path.dirname(sp_glob.BASE_PATH)

    if defaultfile is None:
        defaultfile = "newfile.txt"

    file = None
    wildcard  = create_wildcard("All files", ['*', '*.*'])
    dlg = wx.FileDialog(
        None, message = "Choose a file name...",
        defaultDir  = defaultdir,
        defaultFile = defaultfile,
        wildcard    = wildcard,
        style = wx.FD_SAVE | wx.FD_CHANGE_DIR )

    if dlg.ShowModal() == wx.ID_OK:
        file = dlg.GetPath()

    dlg.Destroy()

    return file