2

I am new to python ubuntu I am learning , I am doing a small project where I have to select multiple folders in the directory using GUI and print the selected folders. I almost finish other task this is last task which is pending.

Example :

Directory A :
    Folder 1;
    Folder 2;
    Folder 3;
    Folder 4;

I like to select only (Folder 1 ; Folder 3; ) And print those names and with path

I got Select Mutiple folder using Pyqt5 But its Pyt5 , I like to work with tkinter or other module.

from tkinter import filedialog
dirselect = filedialog.Directory()
dirs = []
while True:
    d = dirselect.show()
    if not d: break
    dirs.append(d)
dsaran
  • 21
  • 3
  • I believe the right thing to use is `filedialog.askdirectory()` – Delrius Euphoria Sep 14 '20 at 19:52
  • I tried , with filedialog.askdirectory(), its not working – dsaran Sep 14 '20 at 19:59
  • You can able to select only one folder , But I like to select mutiple folders and file. – dsaran Sep 14 '20 at 20:02
  • Then you might want to use `filedialog.askopenfilenames()` but keep in mind, you cannot mix a folder and file, a file should be chose separately and a folder should be chose separately – Delrius Euphoria Sep 14 '20 at 20:12
  • Yes , the problem I am facing. Please chek with link I mentioned, I tried with pyt5 its working perfectly. – dsaran Sep 14 '20 at 20:14
  • pygt5 and tkinter are not same, i dont tkinter has that feature with it. Try googling it?, or if you want you could ask them twice, one for folder and one for file, and concatenate both the set of items to one main set of items – Delrius Euphoria Sep 14 '20 at 20:27
  • 1
    You can get the file/dir names using `os.scandir` and insert the results into a `Listbox` with multiple selection enabled. – Henry Yik Sep 15 '20 at 01:45

0 Answers0