Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import tkinter.ttk as ttk
- from tkinter import *
- from tkinter import filedialog
- class MainApp(tk.Tk):
- def __init__(self):
- tk.Tk.__init__(self)
- self.title("Files")
- self.entries = []
- self.entries.append(tk.Entry(self))
- self.entries[0].grid(row=1, column=1, padx=5, pady=1, sticky="we")
- self.entries.append(tk.Entry(self))
- self.entries[1].grid(row=3, column=1, padx=5, pady=1, sticky="we")
- self.entries.append(tk.Entry(self))
- self.entries[2].grid(row=4, column=1, padx=5, pady=1, sticky="we")
- self.entries.append(tk.Entry(self))
- self.entries[3].grid(row=5, column=1, padx=5, pady=1, sticky="we")
- self.columnconfigure(1, minsize=350)
- self.buttons = []
- self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(0)))
- self.buttons[0].grid(row=1, column=2, padx=5, pady=1, sticky="e")
- self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(1)))
- self.buttons[1].grid(row=3, column=2, padx=5, pady=1, sticky="e")
- self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(2)))
- self.buttons[2].grid(row=4, column=2, padx=5, pady=1, sticky="e")
- self.buttons.append(tk.Button(self, text="...", command=lambda:self.getPath(3)))
- self.buttons[3].grid(row=5, column=2, padx=5, pady=1, sticky="e")
- self.labels = []
- self.labels.append(tk.Label(self, text="Origin Folder:"))
- self.labels[0].grid(row=0, column=0, padx=5, pady=1, sticky="w")
- self.labels.append(tk.Label(self, text="Downloads"))
- self.labels[1].grid(row=1, column=0, padx=5, pady=1, sticky="e")
- self.labels.append(tk.Label(self, text="Target Folders:"))
- self.labels[2].grid(row=2, column=0, padx=5, pady=1, sticky="w")
- self.labels.append(tk.Label(self, text="Pictures"))
- self.labels[3].grid(row=3, column=0, padx=5, pady=1, sticky="e")
- self.labels.append(tk.Label(self, text="Documents"))
- self.labels[4].grid(row=4, column=0, padx=5, pady=1, sticky="e")
- self.labels.append(tk.Label(self, text="Audio"))
- self.labels[5].grid(row=5, column=0, padx=5, pady=1, sticky="e")
- self.okbtn = tk.Button(self, text="Ok", width=10)
- self.okbtn.grid(row=6, column=0, pady=15, padx=15)
- self.cancelbtn = tk.Button(self, text="Cancel", width=10)
- self.cancelbtn.grid(row=6, column=1, pady=15, padx=15)
- def run(self):
- self.mainloop()
- def getPath(self, indx):
- directory = filedialog.askdirectory(initialdir="C:\\")
- self.entries[indx].insert(0, directory)
- if __name__ == '__main__':
- MainApp().run()
Advertisement
Add Comment
Please, Sign In to add comment