Skip to content

Commit 5fb9093

Browse files
authoredDec 1, 2022
Update v1.0.py
1 parent 4c21106 commit 5fb9093

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed
 

‎versions/v1.0.py

+34-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import tkinter.messagebox as msgbox
99
from tkinter.filedialog import (askopenfilename, asksaveasfilename)
1010
import ctypes
11+
import webbrowser
1112

1213
def getTimestamp(line):
1314
timeArray = time.strptime(line[3:].lstrip('|')[:19], "%Y-%m-%dT%H:%M:%S") # 开头日志行类型为2-3位
@@ -103,13 +104,14 @@ def initialize():
103104
continue
104105

105106
global table
106-
table=[[]]
107107

108108
#清空下方的表格Canvas
109109
for row in table:
110110
for widget in row:
111111
widget.destroy()
112112

113+
table=[[]]
114+
113115
#生成标题行
114116
global checkAllVar
115117
checkAllVar = tk.IntVar()
@@ -128,7 +130,7 @@ def initialize():
128130
checkboxVars = []
129131
for i in range(len(fights)):
130132
table.append([])
131-
isWipeColor = ['#d16969','#4ec9b0'][fights[i][4]] # wipe=red, kill=green
133+
isWipeColor = ['#d65','#4ca'][fights[i][4]] # wipe=red, kill=green
132134
checkboxVars.append(tk.IntVar())
133135
table[-1].append(ttk.Checkbutton(tableFrame,text='',variable=checkboxVars[-1])) #table[row][0]: checkbox
134136
table[-1].append(ttk.Label(tableFrame,text=str(i+1),foreground=isWipeColor)) #table[row][1]: index
@@ -139,6 +141,10 @@ def initialize():
139141
table[-1].append(ttk.Label(tableFrame,text=str(fights[i][7])+'/'+str(fights[i][9]))) #table[row][6]: d-
140142
for col in range(len(table[-1])):
141143
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)
142148

143149
def saveLogFile():
144150
export_path = asksaveasfilename(defaultextension='.log', title="Select the log file", filetypes=[("Log File", ".log")])
@@ -197,31 +203,51 @@ def saveLogFile():
197203
screen_x = window.winfo_screenwidth()
198204
screen_y = window.winfo_screenheight()
199205
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__)
200207

201208
ttk.Style().configure(".", font=("微软雅黑", str(int(screen_y/150))))
209+
ttk.Style().configure("update.TLabel", font=("微软雅黑", str(int(screen_y/180))), foreground='#8ae')
202210

203211
button_import = ttk.Button(window,text='Import Log',padding=int(screen_y/150),command=readLogFile)
204212
button_export = ttk.Button(window,text='Export Log',padding=int(screen_y/150),command=saveLogFile)
205213

206214
button_import.place(relx=0.5-0.15,rely=0.06,anchor='center')
207215
button_export.place(relx=0.5+0.15,rely=0.06,anchor='center')
208216

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 = [[]]
209224
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')
211226
tableCanvas = tk.Canvas(outFrame)
212227
tableFrame = ttk.Frame(tableCanvas)
213-
vbar=ttk.Scrollbar(outFrame,orient='vertical',command=tableCanvas.yview)
228+
vbar = ttk.Scrollbar(outFrame,orient='vertical',command=tableCanvas.yview)
214229
tableCanvas.configure(yscrollcommand=vbar.set)
230+
'''
231+
outFrame -> tableCanvas -> tableFrame -> [lines]
232+
-> vbar
233+
'''
215234

216235
vbar.pack(side="right", fill="y")
217236
tableCanvas.pack(side="left", fill="both", expand=True)
218-
window.update()
219237

238+
window.update()
220239
tableCanvas.create_window((int(tableCanvas.winfo_width()/2),0), window=tableFrame, anchor="n")
221-
222-
def onFrameConfigure(canvas):
240+
def onFrameConfigure(canvas): # [1]
223241
canvas.configure(scrollregion=canvas.bbox("all"))
224-
225242
tableFrame.bind("<Configure>", lambda event, tableCanvas=tableCanvas: onFrameConfigure(tableCanvas))
226243

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+
227249
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

Comments
 (0)
Please sign in to comment.