0

I try to make a tool that can merge multiple pdf file types, I use askopenfilenames method, select the files and when I print the files it looks like they are ordered alphabetically. Is there a way to save them in the order of selection? To prevent Python from ordering the files?

My code:

def select_file():
    global file_names
    file_names = askopenfilenames(title='Please select one (any) frame from your set of images.',
                           filetypes=[('Image Files', ['.jpeg', '.jpg', '.png', '.gif',
                                                       '.tiff', '.tif', '.bmp'])])
    for file in list(file_names):
        print(file)
        pdflabel = tk.Label(convertFrame, text=file, bg='#F3F6F6', fg='black')
        pdflabel.pack()

Thanks.

1 Answers1

0

You can't change the order that askopenfilenames returns the files, and there's no way to know the order in which they were selected.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • When selecting the files, there is a field at the bottom of the window, where selected files are added in the selected order. I thought that maybe there is a way to save that particular list. Thanks. – Leonard Basag Aug 22 '22 at 18:27