-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowNameExtension.py
More file actions
87 lines (68 loc) · 2.69 KB
/
Copy pathWindowNameExtension.py
File metadata and controls
87 lines (68 loc) · 2.69 KB
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
#import config module for environmental variability
import config
#import my utility class and function
import MyUtility
#import my multi threading function to upload and download file
from MyMultiThreading import *
#tkinter import
import tkinter as tk
from tkinter import *
from tkinter import ttk
#import my multi threading function to upload and download file
from MyMultiThreading import *
class NameExtensionWindow(tk.Toplevel):
def __init__(self, master):
super().__init__(master)
#save master window
self.master = master
#change icon
img = PhotoImage(file=resource_path(config.icon))
self.iconphoto(False, img)
# configure the root window
self.title('Add prefix/suffix')
# move window center
winWidth = self.winfo_reqwidth()
winwHeight = self.winfo_reqheight()
posRight = int(self.winfo_screenwidth() / 2 - winWidth / 2)
posDown = int(self.winfo_screenheight() / 2 - winwHeight / 2)
self.geometry("+{}+{}".format(posRight, posDown))
#title label
self.lbl_loadFile = tk.Label(self, text="Add a prefix and/or a suffix to the\noutput table names (optional)", width=30,font=config.font_title)
self.lbl_loadFile.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
#Prefix Entry
self.ntr_prefix = tk.Entry(self, width=28)
self.ntr_prefix.grid(row=1,column=0)
#Prefix Label
self.lbl_prefix = tk.Label(self,text='Prefix',width=20,font=config.font_base)
self.lbl_prefix.grid(row=1, column=1, padx=5, pady=5)
#Suffix Entry
self.ntr_suffix = tk.Entry(self, width=28)
self.ntr_suffix.grid(row=2,column=0)
#Suffix Label
self.lbl_suffix = tk.Label(self,text='Suffix',width=20,font=config.font_base)
self.lbl_suffix.grid(row=2, column=1, padx=5, pady=5)
#ok button
self.btn_ok = tk.Button(self, text='Ok', font=config.font_button, width=20,command=self.confirm_text)
self.btn_ok.grid(row=3, column=0, columnspan=2, padx=10, pady=10)
#when I close window
self.protocol("WM_DELETE_WINDOW", self.on_closing)
#put window in front
self.lift()
#prevent touch in other windows
self.grab_set()
def on_closing(self):
#delete itself
self.destroy()
def confirm_text(self):
#get value
if( (len(self.ntr_prefix.get().strip()) > 0) and (not self.ntr_prefix.get().isspace()) ):
self.master.prefix = self.ntr_prefix.get() + "_"
if( (len(self.ntr_suffix.get().strip()) > 0) and (not self.ntr_suffix.get().isspace()) ):
self.master.suffix = "_" + self.ntr_suffix.get()
#delete itself
self.destroy()
#call method for download files from master window
self.master.download()
if __name__ == "__main__":
app = NameExtensionWindow()
app.mainloop()