Q: Python file browsing I can browse folder and files in python but when i selected the file there is no change. I just want to paste the folder or file path in my code. For example,
import PySimpleGUI as sg

sg.theme("DarkTeal2")
layout = [[sg.T("")], [sg.Text("Choose a file: "), sg.Input(), sg.FileBrowse(key="-IN-")], [sg.Button("Submit")]]

###Building Window
window = sg.Window('My File Browser', layout, size=(600, 150))

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == "Exit":
        break
    elif event == "Submit":
        import sys
        sys.stdout = open('../pythonProject3/hedef_dosya.txt', 'w')
        print(values["-IN-"])
        sys.stdout.close()

I want to use the selection in this another .py file
def import_data():
    data = pd.read_csv('x.csv', sep=';')


A: It is not necessary to quit GUI window and save the results to a CSV file, then another script.
With io.StringIO as buffer, then convert it to DataFrame from string directly.
from io import StringIO

import pandas as pd
import PySimpleGUI as sg


sg.theme("DarkTeal2")
layout = [
    [sg.T("")],
    [sg.Text("Choose a file: "),
     sg.Input(), sg.FilesBrowse(key="-IN-")],
    [sg.Button("Submit")],
]

window = sg.Window('My File Browser', layout, size=(600, 150))

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED or event == "Exit":
        break
    elif event == "Submit":
        """ Files in Horizontal """
        buffer = StringIO(values["-IN-"])
        df = pd.read_csv(buffer, sep=";", header=None)
        """ Files in Vertical
        string = '\n'.join(values['-IN-'].split(";"))
        buffer = StringIO(string)
        df = pd.read_csv(buffer, header=None)
        """
        print(df)

window.close()

Horizontal Output
                              0   ...                                13
0  C:/Software/Python/python.exe  ...  C:/Software/Python/pythonw_d.pdb

[1 rows x 14 columns]

Vertical Output
                                    0
0       C:/Software/Python/python.exe
1       C:/Software/Python/python.pdb
2     C:/Software/Python/python_d.exe
3     C:/Software/Python/python_d.pdb
4      C:/Software/Python/python3.dll
5    C:/Software/Python/python3_d.dll
6     C:/Software/Python/python39.dll
7     C:/Software/Python/python39.pdb
8   C:/Software/Python/python39_d.dll
9   C:/Software/Python/python39_d.pdb
10     C:/Software/Python/pythonw.exe
11     C:/Software/Python/pythonw.pdb
12   C:/Software/Python/pythonw_d.exe
13   C:/Software/Python/pythonw_d.pdb

