Quantity limitation for dialog window selecting files?

前端 未结 1 1032
天命终不由人
天命终不由人 2021-01-07 07:32

Python version: 2.7 Tk version: 8.5

Refer to my previous question how to add the selected files from dialog window to a dictionary?

I am trying to select 50

相关标签:
1条回答
  • 2021-01-07 07:59

    I think I can see where the issue is. I have done a little debugging and found that the data type returned into filez is a unicode string (where you seem to be expecting a list or tuple).

    You will need to convert this before your loop. If none of your file names contain spaces this should just be a simple matter of:

    file_list = files.split()
    

    However, if this is not the case then the above will not work and and filenames that contain spaces with be enclosed with curly braces {}.

    This may actually be a bug according to this page. However, a work around is also suggested to convert the string to a tuple:

    file_list=  master.tk.splitlist(filez)
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题