@@ -10,6 +10,7 @@ class GetWidgetsFrame(WidgetsRender, ttk.Frame):
10
10
"""
11
11
The main class of the program is responsible for constructing the form and interaction of elements
12
12
"""
13
+
13
14
def __init__ (self , render_params = None , * args , ** options ):
14
15
"""
15
16
Initialization of the Frame, description of the main elements
@@ -49,42 +50,42 @@ def __init__(self, render_params=None, *args, **options):
49
50
self .scrollbar = ttk .Scrollbar (self .frame1 , orient = "vertical" , command = self .tree .yview )
50
51
self .tree .configure (yscrollcommand = self .scrollbar .set )
51
52
self .create_widgets ()
52
- self .load_config ('config.json' ,True )
53
+ self .load_config ('config.json' , True )
53
54
54
55
def create_widgets (self ):
55
56
"""Building the main widgets at the beginning of program execution"""
56
- self .rgrid (self )
57
- self .rgrid (tk .Label (self , text = "MS Access to SQL Export Tool" , font = ("Helvetica" , 14 )),
58
- dict (row = 0 , column = 0 , columnspan = 3 , pady = 5 ))
59
- self .rgrid (self .lable_frame , dict (row = 1 , column = 0 , columnspan = 3 ))
60
- self .rgrid (self .label_db_path , dict (row = 0 , column = 0 , columnspan = 3 , pady = 5 ))
61
- self .rgrid (self .label_sql_path , dict (row = 1 , column = 0 , columnspan = 3 , pady = 5 ))
62
- self .rgrid (tk .Button (self , text = "MS Access File Open" , command = self .btn_openf , font = ("Helvetica" , 11 )),
63
- dict (row = 2 , column = 0 ))
64
- self .rgrid (tk .Button (self , text = "Save SQL script as..." , command = self .btn_sql_path , font = ("Helvetica" , 11 )),
65
- dict (row = 2 , column = 1 ))
66
- self .rgrid (tk .Button (self , text = " Exit " , command = self .btn_exit , font = ("Helvetica" , 11 )),
67
- dict (row = 2 , column = 2 , columnspan = 2 ))
68
- self .rgrid (self .frame1 , dict (row = 4 , column = 0 , columnspan = 3 ))
69
- self .rgrid (self .tree , dict (row = 0 , column = 0 , pady = 5 ))
70
- self .rgrid (self .scrollbar , dict (row = 0 , column = 3 , sticky = "ns" ))
71
- self .rgrid (tk .Button (self , text = " Save default config " , command = self .save_config , font = ("Helvetica" , 11 )),
72
- dict (row = 5 , column = 0 , ))
73
- self .rgrid (tk .Button (self , text = " Save config as... " , command = self .save_config_as , font = ("Helvetica" , 11 )),
74
- dict (row = 5 , column = 1 , ))
75
- self .rgrid (tk .Button (self , text = " Load config " , command = self .load_config , font = ("Helvetica" , 11 )),
76
- dict (row = 5 , column = 2 , ))
77
- self .rgrid (tk .Button (self , text = " Run! " , command = self .btn_run , font = ("Helvetica" , 12 , "bold" )),
78
- dict (row = 6 , column = 0 , columnspan = 3 , pady = 5 ))
57
+ grid = self .rgrid
58
+ grid (self )
59
+ grid (tk .Label (self , text = "MS Access to SQL Export Tool" , font = ("Helvetica" , 14 )),
60
+ dict (row = 0 , column = 0 , columnspan = 3 , pady = 5 ))
61
+ grid (self .lable_frame , dict (row = 1 , column = 0 , columnspan = 3 ))
62
+ grid (self .label_db_path , dict (row = 0 , column = 0 , columnspan = 3 , pady = 5 ))
63
+ grid (self .label_sql_path , dict (row = 1 , column = 0 , columnspan = 3 , pady = 5 ))
64
+ grid (tk .Button (self , text = "MS Access File Open" , command = self .btn_openf , font = ("Helvetica" , 11 )),
65
+ dict (row = 2 , column = 0 ))
66
+ grid (tk .Button (self , text = "Save SQL script as..." , command = self .btn_sql_path , font = ("Helvetica" , 11 )),
67
+ dict (row = 2 , column = 1 ))
68
+ grid (tk .Button (self , text = " Exit " , command = self .btn_exit , font = ("Helvetica" , 11 )),
69
+ dict (row = 2 , column = 2 , columnspan = 2 ))
70
+ grid (self .frame1 , dict (row = 4 , column = 0 , columnspan = 3 ))
71
+ grid (self .tree , dict (row = 0 , column = 0 , pady = 5 ))
72
+ grid (self .scrollbar , dict (row = 0 , column = 3 , sticky = "ns" ))
73
+ grid (tk .Button (self , text = " Save default config " , command = self .save_config , font = ("Helvetica" , 11 )),
74
+ dict (row = 5 , column = 0 , ))
75
+ grid (tk .Button (self , text = " Save config as... " , command = self .save_config_as , font = ("Helvetica" , 11 )),
76
+ dict (row = 5 , column = 1 , ))
77
+ grid (tk .Button (self , text = " Load config " , command = self .load_config , font = ("Helvetica" , 11 )),
78
+ dict (row = 5 , column = 2 , ))
79
+ grid (tk .Button (self , text = " Run! " , command = self .btn_run , font = ("Helvetica" , 12 , "bold" )),
80
+ dict (row = 6 , column = 0 , columnspan = 3 , pady = 5 ))
79
81
80
82
def recreate_widgets (self ):
81
- self .rgrid (self .tree , dict (row = 0 , column = 0 , pady = 5 ))
82
- self .rgrid (self .scrollbar , dict (row = 0 , column = 3 , sticky = "ns" ))
83
- self .rgrid (self .frame0 , dict (row = 3 , column = 0 , columnspan = 3 , sticky = "e" ))
84
- self .rgrid (self .tree .filter_widget (self .frame0 ),
85
- dict (row = 0 , column = 0 , columnspan = 3 , padx = 5 , pady = 5 , sticky = "ew" ))
86
- self .rgrid (self .tree .checkbox_widget (self .frame0 ),
87
- dict (row = 4 , column = 0 , columnspan = 3 , padx = 5 , pady = 5 , sticky = "e" ))
83
+ grid = self .rgrid
84
+ grid (self .tree , dict (row = 0 , column = 0 , pady = 5 ))
85
+ grid (self .scrollbar , dict (row = 0 , column = 3 , sticky = "ns" ))
86
+ grid (self .frame0 , dict (row = 3 , column = 0 , columnspan = 3 , sticky = "e" ))
87
+ grid (self .tree .filter_widget (self .frame0 ), dict (row = 0 , column = 0 , columnspan = 3 , padx = 5 , pady = 5 , sticky = "ew" ))
88
+ grid (self .tree .checkbox_widget (self .frame0 ), dict (row = 4 , column = 0 , columnspan = 3 , padx = 5 , pady = 5 , sticky = "e" ))
88
89
89
90
def make_tree (self ):
90
91
self .tree .heading ("table" , text = "Table" )
@@ -162,7 +163,7 @@ def save_config(self, file_path='config.json'):
162
163
"tree" : self .tree .df .to_dict ()
163
164
}
164
165
with open (file_path , 'w' ) as f :
165
- json .dump (config , f , indent = 4 )
166
+ json .dump (config , f , indent = 4 )
166
167
167
168
def save_config_as (self ):
168
169
file_path = filedialog .asksaveasfilename (
@@ -174,7 +175,7 @@ def save_config_as(self):
174
175
if file_path :
175
176
self .save_config (file_path )
176
177
177
- def load_config (self , fpath = 'config.json' , loadbyinit = False ):
178
+ def load_config (self , fpath = 'config.json' , loadbyinit = False ):
178
179
try :
179
180
with open (fpath , 'r' ) as f :
180
181
config = json .load (f )
@@ -306,7 +307,7 @@ def resolve_dependencies(self, export_list):
306
307
307
308
return list (export_set ), list (added_tables )
308
309
309
- def export_prepare (self , output_sql_path = "" ):
310
+ def export_prepare (self , output_sql_path = "" ):
310
311
df = self .tree .df
311
312
export_list = df [df .iloc [:, 1 ] == "✔" ]["table" ].to_list ()
312
313
upload_list = df [df .iloc [:, 2 ] == "✔" ]["table" ].to_list ()
@@ -327,7 +328,7 @@ def export_prepare(self, output_sql_path = ""):
327
328
return final_list , upload_list , output_sql_path
328
329
329
330
def export (self ):
330
- export_lists = self .export_prepare ()
331
+ export_lists = self .export_prepare (self . sql_path . get () )
331
332
if not export_lists :
332
333
return
333
334
0 commit comments