-
Notifications
You must be signed in to change notification settings - Fork 61
/
GUI.py
107 lines (84 loc) · 3.09 KB
/
GUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import tkinter as tk
from tkinter import filedialog
import tkinter.ttk as ttk
from icon import ico, github_mark
import base64
import QQ_History
import os
import webbrowser
def Enter():
db_path, qq_self, qq = e1.get(), e2.get(), e3.get()
group = 1 if e4.get() == '私聊' else 2
emoji = 1 if e5.get() == '新' else 2
with_img = True if e6.get() == '是' else False
combine_img = True if e7.get() == '是' else False
if (db_path == "" or qq_self == "" or qq == ""):
info.set("信息不完整!")
return ()
info.set("开始导出")
try:
QQ_History.main(db_path, qq_self, qq, group,
emoji, with_img, combine_img)
info.set("完成")
except Exception as e:
info.set(repr(e))
return ()
def SelectDBPath():
dir = filedialog.askdirectory()
db_path_get.set(dir)
def SelectImgPath():
dir = filedialog.askdirectory()
img_path_get.set(dir)
def url():
webbrowser.open_new("https://github.com/Yiyiyimu/QQ_History_Backup")
root = tk.Tk()
db_path_get, img_path_get, key_get, info = tk.StringVar(
), tk.StringVar(), tk.StringVar(), tk.StringVar()
tmp = open("tmp.ico", "wb+")
tmp.write(base64.b64decode(ico))
tmp.close()
root.iconbitmap("tmp.ico")
os.remove("tmp.ico")
root.title("QQ聊天记录导出")
ttk.Label(root, text="*com.tencent.mobileqq:").grid(row=0, column=0, sticky="e")
e1 = ttk.Entry(root, textvariable=db_path_get)
e1.grid(row=0, column=1, columnspan=2, sticky="ew", pady=3)
ttk.Button(root, text="选择", command=SelectDBPath,
width=5).grid(row=0, column=3)
ttk.Label(root, text="*自己QQ号:").grid(row=1, column=0, sticky="e")
e2 = ttk.Entry(root)
e2.grid(row=1, column=1, columnspan=3, sticky="ew", pady=3)
ttk.Label(root, text="*QQ号/群号:").grid(row=2, column=0, sticky="e")
e3 = ttk.Entry(root)
e3.grid(row=2, column=1, columnspan=3, sticky="ew", pady=3)
ttk.Label(root, text="私聊/群聊:").grid(row=3, column=0, sticky="e")
e4 = ttk.Combobox(root)
e4['values'] = ('私聊', '群聊')
e4.current(0)
e4.grid(row=3, column=1, columnspan=3, sticky="ew", pady=3)
ttk.Label(root, text="表情版本:").grid(row=4, column=0, sticky="e")
e5 = ttk.Combobox(root)
e5['values'] = ('新', '旧')
e5.current(0)
e5.grid(row=4, column=1, columnspan=3, sticky="ew", pady=3)
ttk.Label(root, text="导出图片:").grid(row=5, column=0, sticky="e")
e6 = ttk.Combobox(root)
e6['values'] = ('是', '否')
e6.current(0)
e6.grid(row=5, column=1, columnspan=3, sticky="ew", pady=3)
ttk.Label(root, text="合并图片:").grid(row=6, column=0, sticky="e")
e7 = ttk.Combobox(root)
e7['values'] = ('是', '否')
e7.current(1)
e7.grid(row=6, column=1, columnspan=3, sticky="ew", pady=3)
root.grid_columnconfigure(2, weight=1)
info.set("开始")
ttk.Button(root, textvariable=info, command=Enter).grid(row=7, column=1)
tmp = open("tmp.png", "wb+")
tmp.write(base64.b64decode(github_mark))
tmp.close()
github = tk.PhotoImage(file='tmp.png')
os.remove("tmp.png")
button_img = tk.Button(root, image=github, text='b', command=url, bd=0)
button_img.grid(row=7, rowspan=7, column=0, sticky="ws")
root.mainloop()