@@ -38,7 +38,6 @@ def __init__(self):
38
38
39
39
self .font_size = 10
40
40
self .font_wheight = 0
41
- # self.chg_size()
42
41
# With a Menubar and Toolbar
43
42
self .create_menu ()
44
43
self .create_toolbar ()
@@ -87,7 +86,7 @@ def create_menu(self):
87
86
self .menu_help .add_command (label = 'about' ,
88
87
command = lambda : messagebox .showinfo (message = """
89
88
\n Sqlite_py_manager : a graphic SQLite Client in 1 Python file
90
- \n version 2014-06-09a : 'The magic 8th PEP'
89
+ \n version 2014-06-09b : 'The magic 8th PEP'
91
90
\n (https://github.com/stonebig/baresql/blob/master/examples)""" ))
92
91
93
92
def create_toolbar (self ):
@@ -96,7 +95,7 @@ def create_toolbar(self):
96
95
self .toolbar .pack (side = TOP , fill = X )
97
96
self .tk_icon = self .get_tk_icons ()
98
97
99
- # list of image, action, tootip :
98
+ # list of ( image, action, tooltip) :
100
99
to_show = [
101
100
('refresh_img' , self .actualize_db , "Actualize Databases" ),
102
101
('run_img' , self .run_tab , "Run Script Selection" ),
@@ -170,11 +169,10 @@ def savdb_script(self):
170
169
title = "save database structure in a text file" ,
171
170
filetypes = [("default" , "*.sql" ), ("other" , "*.txt" ),
172
171
("all" , "*.*" )])
173
- if filename == '' :
174
- return
175
- with io .open (filename , 'w' , encoding = 'utf-8' ) as f :
176
- for line in self .conn .iterdump ():
177
- f .write ('%s\n ' % line )
172
+ if filename != '' :
173
+ with io .open (filename , 'w' , encoding = 'utf-8' ) as f :
174
+ for line in self .conn .iterdump ():
175
+ f .write ('%s\n ' % line )
178
176
179
177
def sav_script (self ):
180
178
"""save a script in a file"""
@@ -188,11 +186,11 @@ def sav_script(self):
188
186
title = "save script in a sql file" ,
189
187
filetypes = [("default" , "*.sql" ), ("other" , "*.txt" ),
190
188
("all" , "*.*" )])
191
- if filename = = "" :
192
- return
193
- with io . open ( filename , 'w' , encoding = 'utf-8' ) as f :
194
- f .write ("/*utf-8 bug safety : 你好 мир Artisou à croute blonde */\n " )
195
- f .write (script )
189
+ if filename ! = "" :
190
+ with io . open ( filename , 'w' , encoding = 'utf-8' ) as f :
191
+ if "你好 мир Artisou à croute" not in script :
192
+ f .write ("/*utf-8 tag : 你好 мир Artisou à croute*/\n " )
193
+ f .write (script )
196
194
197
195
def attach_db (self ):
198
196
"""attach an existing database"""
@@ -283,7 +281,8 @@ def exsav_script(self):
283
281
if filename == "" :
284
282
return
285
283
with io .open (filename , 'w' , encoding = 'utf-8' ) as f :
286
- f .write ("/*utf-8 bug safety : 你好 мир Artisou à croute blonde*/\n " )
284
+ if "你好 мир Artisou à croute" not in script :
285
+ f .write ("/*utf-8 tag : 你好 мир Artisou à croute*/\n " )
287
286
self .create_and_add_results (script , active_tab_id , limit = 99 , log = f )
288
287
fw .focus_set () # workaround bug http://bugs.python.org/issue17511
289
288
@@ -329,7 +328,7 @@ def get_tk_icons(self):
329
328
# to create this base 64 from a toto.gif image of 24x24 size do :
330
329
# import base64
331
330
# b64 = base64.encodestring(open(r"toto.gif","rb").read())
332
- # print("'gif_img':'''\\\n" + b64.decode("utf8") + "'''")
331
+ # print("'gif_img': '''\\\n" + b64.decode("utf8") + "'''")
333
332
icons = {
334
333
'run_img' : '''\
335
334
R0lGODdhGAAYAJkAADOqM////wCqMwAAACwAAAAAGAAYAAACM4SPqcvt7wJ8oU5W8025b9OFW0hO
@@ -404,10 +403,7 @@ def get_tk_icons(self):
404
403
xlzceksqu6ET7JwtLRrhwNt+1HdDUQAAOw==
405
404
'''
406
405
}
407
- # transform 'in place' base64 icons into tk_icons
408
- for key , value in icons .items ():
409
- icons [key ] = PhotoImage (data = value )
410
- return icons
406
+ return {k : PhotoImage (data = v ) for k , v in icons .items ()}
411
407
412
408
def createToolTip (self , widget , text ):
413
409
"""create a tooptip box for a widget."""
@@ -1123,8 +1119,8 @@ def close(self):
1123
1119
1124
1120
def iterdump (self ):
1125
1121
"""dump the database (add tweaks over the default dump)"""
1126
- # force detection of utf-8
1127
- yield ("/*utf-8 bug safety : 你好 мир Artisou à croute blonde */\n " )
1122
+ # force detection of utf-8 by placing an only utf-8 comment at top
1123
+ yield ("/*utf-8 tag : 你好 мир Artisou à croute*/\n " )
1128
1124
# add the Python functions pydef
1129
1125
for k in self .conn_def .values ():
1130
1126
yield (k ['pydef' ] + ";\n " )
@@ -1141,7 +1137,7 @@ def iterdump(self):
1141
1137
for row in self .conn .execute ("PRAGMA foreign_keys" ):
1142
1138
flag = 'ON' if row [0 ] == 1 else 'OFF'
1143
1139
yield ("PRAGMA foreign_keys = %s;/*if SQlite*/;" % flag )
1144
- yield ("PRAGMA foreign_keys = %s;/*if SQlite, twice */;" % flag )
1140
+ yield ("PRAGMA foreign_keys = %s;/*if SQlite bug */;" % flag )
1145
1141
yield ("PRAGMA foreign_key_check;/*if SQLite, check*/;" )
1146
1142
yield ("\n /*SET foreign_key_checks = %s;/*if Mysql*/;\n " % row [0 ])
1147
1143
0 commit comments