Advertisement
Ruddog

askdirectory_fails

Apr 5th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. from tkinter import *
  2. from tkinter.filedialog import askdirectory
  3. import os
  4. master = Tk()
  5. def callback():
  6.       enterSearchPath=(askdirectory())#Places path into variable
  7.       print(enterSearchPath)
  8.       for folderName, subfolders, filenames in os.walk(enterSearchPath):              
  9.             for filename in filenames:
  10.                   try:
  11.                         print(filename)                
  12.                   except UnicodeEncodeError:
  13.                         print("UnicodeEncodeError: 'UCS-2' ")
  14.  
  15.  
  16. b = Button(master, text="get", width=10, command=callback)
  17. b.pack()
  18.  
  19. mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement