Skip to content

[Feature]: FilesBrowse等で複数ファイル選択時にパス同士の区切り文字を自由に変更できるようにしてほしい #148

@t-yumo

Description

@t-yumo

Overview

FilesBrowse(またはFileBrowseやpopup_get_fileのmultiple_files=True時)で複数ファイル選択時に
パス同士の区切り文字を自由に変更できるようにしてほしい。

Background

現状では複数ファイルを選択したときのパス同士の区切り文字がセミコロンになっているため、
Windowsでファイル名にセミコロンが含まれているとうまくファイルのパスを分割できない。

Proposal

FreeSimpleGUI(PySimpleGUI)にあるfiles_delimiterパラメータを実装してほしい。

いつもお世話になっております。
もし可能でしたらご検討のほどよろしくお願いいたします。

Additional context

サンプルプログラム

import FreeSimpleGUI as sg
import time

layout = [[sg.InputText("", size=(25,1), key="-file-", readonly=True),
           sg.FilesBrowse("選択", files_delimiter="|")],  # 区切り文字をWindowsのファイル名で使用できない|に変更
          [sg.Button("実行", key="-btn-")],
          [sg.Text(key="-txt1-")],
          [sg.Text(key="-txt2-")]]

window = sg.Window("テストプログラム", layout=layout, font=(None,14))


# メイン処理
def execute():

    if len(values['-file-']) == 0:
        window["-txt1-"].update("ファイルを選択してください。")
        window["-txt2-"].update("")
        return

    path_list = f"{values['-file-']}".split("|") # 区切り文字の|で分割する
    
    for i, file_path in enumerate(path_list, 1):
        window["-txt1-"].update(f"{i}個目のファイル")
        window["-txt2-"].update(f"{file_path}")
        window.refresh()
        time.sleep(2)

    window["-txt1-"].update("")
    window["-txt2-"].update("")


# メインループ
while True:
    event, values = window.read()

    if event == "-btn-":
        execute()       

    if event == sg.WIN_CLOSED:
        break

window.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions