import tkinter as tk
import pickle
from tkinter import messagebox
window = tk.Tk()
window.title('词典')
window.geometry('500x500')
window.resizable(False,False)
window.config(bg = 'red')
window.attributes('-alpha',0.8)
list1 = []
dict1 = {}
var4 = tk.StringVar()
Listbox = tk.Listbox(window,listvariable = var4,width = 30,height = 20).place(x = 150,y = 120)
Frame = tk.Frame(window,width = 500,height = 500)
canvas = tk.Canvas(window,bg = 'grey',width = 500,height = 100).pack()
canvas2 = tk.Canvas(window,bg = 'black',width = 100,height = 180).place(x = 13,y = 180)
canvas3 = tk.Canvas(window,bg = 'black',width = 100,height = 50).place(x = 380,y = 185)
canvas4 = tk.Canvas(window,bg = 'black',width = 100,height = 50).place(x = 380,y = 285)
Entry = tk.Entry(canvas3,text = '输入新词',width = 10,bg = 'white')
Entry.place(x = 395,y = 200)
Entry2 = tk.Entry(canvas3,text = '输入注释',width = 10,bg = 'white')
Entry2.place(x = 395,y = 300)
Text5 = Entry.get()
Text6 = Entry2.get()
def click1():
global list1,Entry,var,dict1,Text5,Text6
msgbox = tk.messagebox.showinfo(title = '提示',message = '已添加至选择框')
dict1[Text5] = Text6
f = open('e:/dict6.txt','ab')
pickle.dump(dict1,f)
f.close()
def click2():
global Entry,var,dict1,Text5,Text6,var4
z = open('e:/dict6.txt','rb')
n = pickle.load(z)
for val,key in n.items():
if Text5 in val:
var4 = n[Text5]
print(n)
else:
tk.messagebox.showinfo(title = '提醒',message = '所查单词不在词库内')
label = tk.Label(window,bg = 'white',textvariable = var4,width = 60,height = 2).place(x = 35,y = 50)
Button1 = tk.Button(window,text = '添加新词',bg = 'yellow',width = 10,height = 2,command = click1).place(x = 25,y = 200)
Button2 = tk.Button(window,text = '查找词汇',bg = 'yellow',width = 10,height = 2).place(x = 25,y = 250)
Button3 = tk.Button(window,text = '显示结果',bg = 'yellow',width = 10,height = 2,command = click2).place(x = 25,y = 300)
window.mainloop()
import pickle
from tkinter import messagebox
window = tk.Tk()
window.title('词典')
window.geometry('500x500')
window.resizable(False,False)
window.config(bg = 'red')
window.attributes('-alpha',0.8)
list1 = []
dict1 = {}
var4 = tk.StringVar()
Listbox = tk.Listbox(window,listvariable = var4,width = 30,height = 20).place(x = 150,y = 120)
Frame = tk.Frame(window,width = 500,height = 500)
canvas = tk.Canvas(window,bg = 'grey',width = 500,height = 100).pack()
canvas2 = tk.Canvas(window,bg = 'black',width = 100,height = 180).place(x = 13,y = 180)
canvas3 = tk.Canvas(window,bg = 'black',width = 100,height = 50).place(x = 380,y = 185)
canvas4 = tk.Canvas(window,bg = 'black',width = 100,height = 50).place(x = 380,y = 285)
Entry = tk.Entry(canvas3,text = '输入新词',width = 10,bg = 'white')
Entry.place(x = 395,y = 200)
Entry2 = tk.Entry(canvas3,text = '输入注释',width = 10,bg = 'white')
Entry2.place(x = 395,y = 300)
Text5 = Entry.get()
Text6 = Entry2.get()
def click1():
global list1,Entry,var,dict1,Text5,Text6
msgbox = tk.messagebox.showinfo(title = '提示',message = '已添加至选择框')
dict1[Text5] = Text6
f = open('e:/dict6.txt','ab')
pickle.dump(dict1,f)
f.close()
def click2():
global Entry,var,dict1,Text5,Text6,var4
z = open('e:/dict6.txt','rb')
n = pickle.load(z)
for val,key in n.items():
if Text5 in val:
var4 = n[Text5]
print(n)
else:
tk.messagebox.showinfo(title = '提醒',message = '所查单词不在词库内')
label = tk.Label(window,bg = 'white',textvariable = var4,width = 60,height = 2).place(x = 35,y = 50)
Button1 = tk.Button(window,text = '添加新词',bg = 'yellow',width = 10,height = 2,command = click1).place(x = 25,y = 200)
Button2 = tk.Button(window,text = '查找词汇',bg = 'yellow',width = 10,height = 2).place(x = 25,y = 250)
Button3 = tk.Button(window,text = '显示结果',bg = 'yellow',width = 10,height = 2,command = click2).place(x = 25,y = 300)
window.mainloop()