@@ -52,15 +52,18 @@ def create_widgets(self):
5252 self .rgrid (tk .Label (self , text = "MS Access to SQL Export Tool" , font = ("Helvetica" , 14 )),
5353 dict (row = 0 , column = 0 , columnspan = 3 , pady = 5 ))
5454 self .rgrid (self .label1 , dict (row = 1 , column = 0 , columnspan = 3 ))
55- self .rgrid (tk .Button (self , text = "MS Access File Open" , command = self .btn_openf ),
55+ self .rgrid (tk .Button (self , text = "MS Access File Open" , command = self .btn_openf , font = ( "Helvetica" , 11 ) ),
5656 dict (row = 2 , column = 0 , columnspan = 2 ))
57- self .rgrid (tk .Button (self , text = " Exit " , command = self .btn_exit ), dict (row = 2 , column = 2 , columnspan = 2 ))
57+ self .rgrid (tk .Button (self , text = " Exit " , command = self .btn_exit , font = ("Helvetica" , 11 )),
58+ dict (row = 2 , column = 2 , columnspan = 2 ))
5859 self .rgrid (self .frame1 , dict (row = 4 , column = 0 , columnspan = 3 ))
5960 self .rgrid (self .tree , dict (row = 0 , column = 0 , pady = 5 ))
6061 self .rgrid (self .scrollbar , dict (row = 0 , column = 3 , sticky = "ns" ))
61- self .rgrid (tk .Button (self , text = " Save config " , command = self .save_config , font = ("Helvetica" , 12 )),
62+ self .rgrid (tk .Button (self , text = " Save config " , command = self .save_config , font = ("Helvetica" , 11 )),
6263 dict (row = 5 , column = 0 , ))
63- self .rgrid (tk .Button (self , text = " Load config " , command = self .load_config , font = ("Helvetica" , 12 )),
64+ self .rgrid (tk .Button (self , text = " Save config as " , command = self .save_config_as , font = ("Helvetica" , 11 )),
65+ dict (row = 5 , column = 1 , ))
66+ self .rgrid (tk .Button (self , text = " Load config " , command = self .load_config , font = ("Helvetica" , 11 )),
6467 dict (row = 5 , column = 2 , ))
6568 self .rgrid (tk .Button (self , text = " Run! " , command = self .btn_run , font = ("Helvetica" , 12 )),
6669 dict (row = 6 , column = 0 , columnspan = 3 , ))
@@ -131,15 +134,25 @@ def btn_openf(self):
131134 self .db_path .set (db_path )
132135 self .update_widgets ()
133136
134- def save_config (self ):
137+ def save_config (self , file_path = 'config.json' ):
135138 config = {
136139 "info" : "MS Access to SQL Export configuration file" ,
137140 "db_path" : self .db_path .get (),
138141 "tree" : self .tree .df .to_dict ()
139142 }
140- with open ('config.json' , 'w' ) as f :
143+ with open (file_path , 'w' ) as f :
141144 json .dump (config , f , indent = 4 )
142145
146+ def save_config_as (self ):
147+ file_path = filedialog .asksaveasfilename (
148+ title = "Save configuration as(" ,
149+ defaultextension = ".json" ,
150+ initialfile = "config.json" ,
151+ filetypes = [("JSON files" , "*.json" )]
152+ )
153+ if file_path :
154+ self .save_config (file_path )
155+
143156 def load_config (self , fpath = 'config.json' , loadbyinit = False ):
144157 try :
145158 with open (fpath , 'r' ) as f :
0 commit comments