-
Notifications
You must be signed in to change notification settings - Fork 0
/
choosingDirectory.py
97 lines (71 loc) · 2.74 KB
/
choosingDirectory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import tkinter as tk
from tkinter import *
from tkinter import filedialog
import os
path = "C:/"
finall = path+"\copy"
try:
os.path.isdir('copy')
except:
os.mkdir(finall)
finallpath = finall+"\path.txt"
finallfolder = finall+"/folder.txt"
class Widget:
def DestinationBrowse(self):
self.destinationdirectory = filedialog.askdirectory(initialdir =os.getcwd())
root.destinationText.insert('1', self.destinationdirectory)
def savePath(self):
p = open(finallpath, 'w+')
p.write(root.destinationText.get())
p.close()
def saveFolders(self):
f = open(finallfolder, 'w+')
f.write(root.foldersText.get())
f.close()
def exitApp(self):
exit()
w = Widget()
def CreateWidgets():
destinationLabel = Label(root, text ="Wybierz scieżkę: ",
bg ="#E8D579")
destinationLabel.grid(row = 1, column = 0,
pady = 5, padx = 5)
root.destinationText = Entry(root, width = 50,
textvariable = destinationLocation)
root.destinationText.grid(row = 1, column = 1,
pady = 5, padx = 5,
columnspan = 2)
dest_browseButton = Button(root, text ="Wyszukaj",
command = w.DestinationBrowse, width = 15)
dest_browseButton.grid(row = 1, column = 3,
pady = 5, padx = 5)
foldersLabel = Label(root, text ="Wybierz liczbę folderów: ",
bg ="#E8D579")
foldersLabel.grid(row = 2, column = 0,
pady = 5, padx = 5)
root.foldersText = Entry(root, width = 50,
textvariable = foldersLocation)
root.foldersText.grid(row = 2, column = 1,
pady = 5, padx = 5,
columnspan = 2)
acceptButton = Button(root, text ="Zatwierdź scieżkę",
command = w.savePath, width = 15)
acceptButton.grid(row = 1, column = 4,
pady = 5, padx = 5)
numberButton = Button(root, text ="Zatwierdź liczbę folderów",
command = w.saveFolders, width = 20)
numberButton.grid(row = 2, column = 4,
pady = 5, padx = 5)
exitButton = Button(root, text ="Wyjdź",
command = w.exitApp, width = 20)
exitButton.grid(row = 4, column = 2,
pady = 5, padx = 5)
root = tk.Tk()
root.geometry("830x120")
root.title("Ustawienia")
root.config(background = "black")
# Creating tkinter variable
destinationLocation = StringVar()
foldersLocation = IntVar()
CreateWidgets()
root.mainloop()