1

I am trying to use the browse function in PySimpleGUI. I have used PySimpleGUI file browser specific file type to find out how to browse. However there are two file types that I want to choose from and multiple files need to be selected for this to work. My question:

How do you use the browse function for browsing two types of files? and also How do you allow multiple files to be browsed? and finally How do you tell each file apart?

I know that there is a key function for getting data but how can I do that for more than one file.

In case you are a tiny bit confused:

The user must select the browse function and must be able to choose from .txt and .Docx files while selecting more than one file. The program must be able to tell the difference between the files so a function can be run on each file separately.

My code so far:

import PySimpleGUI as sg

sg.theme('DarkAmber')   # Add a touch of color
# All the stuff inside your window.
layout = [ [sg.FileBrowse(file_types=(("Text Files", "*.txt"),))],
            [sg.Button('Lets GO!!!')]
]

# Create the Window
window = sg.Window('Test', layout).Finalize()
window.Maximize()

Can someone finish this code?

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
Thomas
  • 1,214
  • 4
  • 18
  • 45
  • Never worked with it, but according to the documentation this should work: `file_types=(("Text Files", "*.txt"),("CSV Files", "*.csv"),)` – Matthias Apr 17 '20 at 15:33
  • It works - I have asked another question on giving this chosen document a key. Can you post that as an answer and I will give you a tick? @Matthias – Thomas Apr 17 '20 at 17:05
  • Leave it for someone else. I'm mo point hunter. :) – Matthias Apr 17 '20 at 18:23

1 Answers1

2

According to the documentation:

file_types=(("Text Files", "*.txt"),("CSV Files", "*.csv"),)

works.

Thomas
  • 1,214
  • 4
  • 18
  • 45