Guest User

Untitled

a guest
Jan 12th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. import tkinter as tk
  2. import tkinter.ttk as ttk
  3. from tkinter import *
  4. from tkinter import filedialog
  5.  
  6. class MainApp(tk.Tk):
  7. def __init__(self):
  8. tk.Tk.__init__(self)
  9. self.title("Files")
  10.  
  11. self.entries = []
  12. self.entries.append(tk.Entry(self))
  13. self.entries[0].grid(row=1, column=1, padx=5, pady=1, sticky="we")
  14. self.entries.append(tk.Entry(self))
  15. self.entries[1].grid(row=3, column=1, padx=5, pady=1, sticky="we")
  16. self.entries.append(tk.Entry(self))
  17. self.entries[2].grid(row=4, column=1, padx=5, pady=1, sticky="we")
  18. self.entries.append(tk.Entry(self))
  19. self.entries[3].grid(row=5, column=1, padx=5, pady=1, sticky="we")
  20. self.columnconfigure(1, minsize=350)
  21.  
  22. self.buttons = []
  23. self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(0)))
  24. self.buttons[0].grid(row=1, column=2, padx=5, pady=1, sticky="e")
  25. self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(1)))
  26. self.buttons[1].grid(row=3, column=2, padx=5, pady=1, sticky="e")
  27. self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(2)))
  28. self.buttons[2].grid(row=4, column=2, padx=5, pady=1, sticky="e")
  29. self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(3)))
  30. self.buttons[3].grid(row=5, column=2, padx=5, pady=1, sticky="e")
  31.  
  32. self.labels = []
  33. self.labels.append(tk.Label(self, text="Origin Folder:"))
  34. self.labels[0].grid(row=0, column=0, padx=5, pady=1, sticky="w")
  35. self.labels.append(tk.Label(self, text="Downloads"))
  36. self.labels[1].grid(row=1, column=0, padx=5, pady=1, sticky="e")
  37. self.labels.append(tk.Label(self, text="Target Folders:"))
  38. self.labels[2].grid(row=2, column=0, padx=5, pady=1, sticky="w")
  39. self.labels.append(tk.Label(self, text="Pictures"))
  40. self.labels[3].grid(row=3, column=0, padx=5, pady=1, sticky="e")
  41. self.labels.append(tk.Label(self, text="Documents"))
  42. self.labels[4].grid(row=4, column=0, padx=5, pady=1, sticky="e")
  43. self.labels.append(tk.Label(self, text="Audio"))
  44. self.labels[5].grid(row=5, column=0, padx=5, pady=1, sticky="e")
  45.  
  46. self.okbtn = tk.Button(self, text="Ok", width=10)
  47. self.okbtn.grid(row=6, column=0, pady=15, padx=15)
  48. self.cancelbtn = tk.Button(self, text="Cancel", width=10)
  49. self.cancelbtn.grid(row=6, column=1, pady=15, padx=15)
  50.  
  51. def run(self):
  52. self.mainloop()
  53.  
  54. def getPath(self, indx):
  55. directory = filedialog.askdirectory(initialdir="C:\\")
  56. self.entries[indx].insert(0, directory)
  57.  
  58. if __name__ == '__main__':
  59. MainApp().run()
Advertisement
Add Comment
Please, Sign In to add comment