8
8
import tkinter .messagebox as msgbox
9
9
from tkinter .filedialog import (askopenfilename , asksaveasfilename )
10
10
import ctypes
11
+ import webbrowser
11
12
12
13
def getTimestamp (line ):
13
14
timeArray = time .strptime (line [3 :].lstrip ('|' )[:19 ], "%Y-%m-%dT%H:%M:%S" ) # 开头日志行类型为2-3位
@@ -103,13 +104,14 @@ def initialize():
103
104
continue
104
105
105
106
global table
106
- table = [[]]
107
107
108
108
#清空下方的表格Canvas
109
109
for row in table :
110
110
for widget in row :
111
111
widget .destroy ()
112
112
113
+ table = [[]]
114
+
113
115
#生成标题行
114
116
global checkAllVar
115
117
checkAllVar = tk .IntVar ()
@@ -128,7 +130,7 @@ def initialize():
128
130
checkboxVars = []
129
131
for i in range (len (fights )):
130
132
table .append ([])
131
- isWipeColor = ['#d16969 ' ,'#4ec9b0 ' ][fights [i ][4 ]] # wipe=red, kill=green
133
+ isWipeColor = ['#d65 ' ,'#4ca ' ][fights [i ][4 ]] # wipe=red, kill=green
132
134
checkboxVars .append (tk .IntVar ())
133
135
table [- 1 ].append (ttk .Checkbutton (tableFrame ,text = '' ,variable = checkboxVars [- 1 ])) #table[row][0]: checkbox
134
136
table [- 1 ].append (ttk .Label (tableFrame ,text = str (i + 1 ),foreground = isWipeColor )) #table[row][1]: index
@@ -139,6 +141,10 @@ def initialize():
139
141
table [- 1 ].append (ttk .Label (tableFrame ,text = str (fights [i ][7 ])+ '/' + str (fights [i ][9 ]))) #table[row][6]: d-
140
142
for col in range (len (table [- 1 ])):
141
143
table [- 1 ][col ].grid (row = i + 1 ,column = col ,padx = int (screen_y / 100 ),pady = 5 )
144
+
145
+ for row in table :
146
+ for widget in row :
147
+ widget .bind ('<MouseWheel>' ,processWheel )
142
148
143
149
def saveLogFile ():
144
150
export_path = asksaveasfilename (defaultextension = '.log' , title = "Select the log file" , filetypes = [("Log File" , ".log" )])
@@ -197,31 +203,51 @@ def saveLogFile():
197
203
screen_x = window .winfo_screenwidth ()
198
204
screen_y = window .winfo_screenheight ()
199
205
window .geometry ('%dx%d+%d+%d' % (int (screen_x * 0.7 ), int (screen_y * 0.7 ), int (screen_x * 0.15 ), int (screen_y * 0.12 )))
206
+ window .title ('FFXIVLogSeparate v' + __version__ + ' by ' + __author__ )
200
207
201
208
ttk .Style ().configure ("." , font = ("微软雅黑" , str (int (screen_y / 150 ))))
209
+ ttk .Style ().configure ("update.TLabel" , font = ("微软雅黑" , str (int (screen_y / 180 ))), foreground = '#8ae' )
202
210
203
211
button_import = ttk .Button (window ,text = 'Import Log' ,padding = int (screen_y / 150 ),command = readLogFile )
204
212
button_export = ttk .Button (window ,text = 'Export Log' ,padding = int (screen_y / 150 ),command = saveLogFile )
205
213
206
214
button_import .place (relx = 0.5 - 0.15 ,rely = 0.06 ,anchor = 'center' )
207
215
button_export .place (relx = 0.5 + 0.15 ,rely = 0.06 ,anchor = 'center' )
208
216
217
+ updateLabel = ttk .Label (window ,text = '[Check for update]' ,style = 'update.TLabel' )
218
+ updateLabel .place (relx = 0.5 ,rely = 0.98 ,anchor = 's' )
219
+ def checkUpdate (event ):
220
+ webbrowser .open ("https://github.com/MnFeN/FFXIVLogSeparate/releases" , new = 0 )
221
+ updateLabel .bind ("<Button-1>" ,checkUpdate )
222
+
223
+ table = [[]]
209
224
outFrame = ttk .Frame (window )
210
- outFrame .place (relx = 0.5 ,rely = 0.12 ,relheight = 0.78 ,relwidth = 1 ,anchor = 'n' )
225
+ outFrame .place (relx = 0.5 ,rely = 0.12 ,relheight = 0.76 ,relwidth = 1 ,anchor = 'n' )
211
226
tableCanvas = tk .Canvas (outFrame )
212
227
tableFrame = ttk .Frame (tableCanvas )
213
- vbar = ttk .Scrollbar (outFrame ,orient = 'vertical' ,command = tableCanvas .yview )
228
+ vbar = ttk .Scrollbar (outFrame ,orient = 'vertical' ,command = tableCanvas .yview )
214
229
tableCanvas .configure (yscrollcommand = vbar .set )
230
+ '''
231
+ outFrame -> tableCanvas -> tableFrame -> [lines]
232
+ -> vbar
233
+ '''
215
234
216
235
vbar .pack (side = "right" , fill = "y" )
217
236
tableCanvas .pack (side = "left" , fill = "both" , expand = True )
218
- window .update ()
219
237
238
+ window .update ()
220
239
tableCanvas .create_window ((int (tableCanvas .winfo_width ()/ 2 ),0 ), window = tableFrame , anchor = "n" )
221
-
222
- def onFrameConfigure (canvas ):
240
+ def onFrameConfigure (canvas ): # [1]
223
241
canvas .configure (scrollregion = canvas .bbox ("all" ))
224
-
225
242
tableFrame .bind ("<Configure>" , lambda event , tableCanvas = tableCanvas : onFrameConfigure (tableCanvas ))
226
243
244
+ def processWheel (event ): # [2]
245
+ tableCanvas .yview_scroll (int (- event .delta / 100 ),'units' )
246
+ tableFrame .bind ('<MouseWheel>' ,processWheel )
247
+ tableCanvas .bind ('<MouseWheel>' ,processWheel )
248
+
227
249
window .mainloop ()
250
+
251
+ # References:
252
+ # [1] canvas嵌套的frame添加滚动条:https://stackoverflow.com/questions/3085696/adding-a-scrollbar-to-a-group-of-widgets-in-tkinter
253
+ # [2] 鼠标滚轮滚动canvas:https://www.zhihu.com/question/385891705
0 commit comments