@@ -38,12 +38,15 @@ def __init__(self, render_params=None, *args, **options):
38
38
}}
39
39
self .db_path = tk .StringVar (self , "" )
40
40
self .sql_path = tk .StringVar (self , "" )
41
+ self .log_path = tk .StringVar (self , "" )
41
42
self .config_path = tk .StringVar (self , "" )
42
43
self .lable_frame = ttk .Frame (self , padding = (2 , 2 ))
43
44
self .label_db_path = ttk .Label (self .lable_frame , text = "MS Access database" , font = ("Helvetica" , 12 ),
44
45
wraplength = 650 )
45
46
self .label_sql_path = ttk .Label (self .lable_frame , text = "Exported SQL script:" , font = ("Helvetica" , 12 ),
46
47
wraplength = 650 )
48
+ self .log_frame = ttk .Frame (self , borderwidth = 1 , relief = "solid" , padding = (2 , 2 ))
49
+ self .label_log_path = ttk .Label (self .log_frame , text = "..." , font = ("Helvetica" , 12 ), wraplength = 650 )
47
50
self .frame0 = ttk .Frame (self , width = 240 , borderwidth = 1 , relief = "solid" , padding = (2 , 2 ))
48
51
self .frame1 = ttk .Frame (self , width = 100 , borderwidth = 1 , relief = "solid" , padding = (2 , 2 ))
49
52
self .tree = TreeviewDataFrame (self .frame1 , columns = ("table" , "export" , "data" ), show = "headings" )
@@ -56,7 +59,11 @@ def __init__(self, render_params=None, *args, **options):
56
59
self .load_config ('config.json' , True )
57
60
58
61
def create_widgets (self ):
59
- """Building the main widgets at the beginning of program execution"""
62
+ """
63
+ Building the main widgets at the beginning of program execution
64
+ Returns:
65
+
66
+ """
60
67
grid = self .rgrid
61
68
grid (self )
62
69
grid (tk .Label (self , text = "MS Access to SQL Export Tool" , font = ("Helvetica" , 14 )),
@@ -79,8 +86,15 @@ def create_widgets(self):
79
86
dict (row = 5 , column = 1 , ))
80
87
grid (tk .Button (self , text = " Load config " , command = self .load_config , font = ("Helvetica" , 11 )),
81
88
dict (row = 5 , column = 2 , ))
89
+ grid (self .log_frame , dict (row = 6 , column = 0 , columnspan = 3 , pady = 5 ))
90
+ self .log_frame .grid_columnconfigure (1 , weight = 1 )
91
+ grid (tk .Button (self .log_frame , text = " Logging in file: " , command = self .btn_log , font = ("Helvetica" , 11 )),
92
+ dict (row = 0 , column = 0 , pady = 5 ))
93
+ grid (self .label_log_path , dict (row = 0 , column = 1 , pady = 5 ))
94
+ grid (tk .Button (self .log_frame , text = "X" , command = self .btn_log_delete , font = ("Helvetica" , 11 )),
95
+ dict (row = 0 , column = 2 , padx = 5 , pady = 5 , sticky = "e" ))
82
96
grid (tk .Button (self , text = " Run! " , command = self .btn_run , font = ("Helvetica" , 12 , "bold" )),
83
- dict (row = 6 , column = 0 , columnspan = 3 , pady = 5 ))
97
+ dict (row = 7 , column = 0 , columnspan = 3 , pady = 5 ))
84
98
85
99
def recreate_widgets (self ):
86
100
grid = self .rgrid
@@ -119,6 +133,14 @@ def update_column_style(self):
119
133
self .tree .item (item_id , tags = ("normal" ,))
120
134
121
135
def on_filter_updated (self , event ):
136
+ """
137
+
138
+ Args:
139
+ event:
140
+
141
+ Returns:
142
+
143
+ """
122
144
pass
123
145
124
146
def on_check_all_updated (self , event ):
@@ -128,6 +150,18 @@ def on_toggle_cell(self, event):
128
150
"""Handles cell clicks to change flags."""
129
151
self .update_column_style ()
130
152
153
+ def btn_log (self ):
154
+ log_path = filedialog .asksaveasfilename (
155
+ filetypes = [("Log files" , "*.log" )],
156
+ initialfile = "export-msaccess-sql.log"
157
+ )
158
+ self .log_path .set (log_path )
159
+ self .update_label_log ()
160
+
161
+ def btn_log_delete (self ):
162
+ self .log_path .set ("" )
163
+ self .update_label_log ()
164
+
131
165
def btn_run (self ):
132
166
"""
133
167
Implementation of the "Run" button
@@ -160,6 +194,7 @@ def save_config(self, file_path='config.json'):
160
194
"info" : "MS Access to SQL Export configuration file" ,
161
195
"db_path" : self .db_path .get (),
162
196
"sql_path" : self .sql_path .get (),
197
+ "log_path" : self .log_path .get (),
163
198
"tree" : self .tree .df .to_dict ()
164
199
}
165
200
with open (file_path , 'w' ) as f :
@@ -181,9 +216,11 @@ def load_config(self, fpath='config.json', loadbyinit=False):
181
216
with open (fpath , 'r' ) as f :
182
217
config = json .load (f )
183
218
184
- if config [ 'info' ] and (config ['info' ] == "MS Access to SQL Export configuration file" ):
219
+ if ( 'info' in config ) and (config ['info' ] == "MS Access to SQL Export configuration file" ):
185
220
self .db_path .set (config ["db_path" ])
186
221
self .sql_path .set (config ["sql_path" ])
222
+ if "log_path" in config :
223
+ self .log_path .set (config ["log_path" ])
187
224
self .update_widgets ()
188
225
self .tree .df = self .tree .df .from_dict (config ["tree" ])
189
226
self .tree .rebuild_tree ()
@@ -207,9 +244,13 @@ def update_label_db(self):
207
244
def update_label_sql (self ):
208
245
self .label_sql_path ['text' ] = f"Exported SQL script: { self .sql_path .get ()} "
209
246
247
+ def update_label_log (self ):
248
+ self .label_log_path ['text' ] = f"{ self .log_path .get ()} "
249
+
210
250
def update_widgets (self ):
211
251
self .update_label_db ()
212
252
self .update_label_sql ()
253
+ self .update_label_log ()
213
254
214
255
def show_permission_warning (self ):
215
256
def open_link (event ):
0 commit comments