直接上运行截图(代码在后面)
开始界面
使用navicat查看mysql数据库中的数据
单词查询功能测试
本地翻译一个本地数据库中有的单词
本地翻译一个本地数据库中没有的单词
爬取有道官网进行在线翻译
单词录入功能测试
我是录入了很多单词,这里只放一张图片
然后查看数据库中的数据
单词测试功能测试
点击单词测试结果如下
难度选择中等后点击生成结果如下
在下面的输入框中输入你的答案然后点击提交,程序将会把你的试卷改出来
注意事项
这个程序是我好久以前用当时的电脑做的,现在电脑中本程序所需要的的数据库表并不全,大家如果需要使用的话,可以根据我的代码自己创建数据库,程序中的所有功能都是可以正常使用的。
源代码(如转发请注明出处,谢谢)
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 24 13:06:14 2019
@author: 一叶落而知天下秋
"""
import random
import wx
import pymysql
from urllib import request, parse
import json
import pymysql
class priframe(wx.Frame):
def __init__(self,sup):
wx.Frame.__init__(self,parent=sup,title='多多瑜教育管理中心',pos=(650,300),size=(900,600))
panel=wx.Panel(self)
image_file = '背景2.png'
to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
panel.bitmap = wx.StaticBitmap(panel,-1, to_bmp_image, (0, 0))
#set_title = '%s %d x %d' % (image_file,200,400)
#self.SetTitle(set_title)
'''panel.Bind(wx.EVT_ERASE_BACKGROUND,self.OnEraseBack)
def OnEraseBack(self,event):
dc = event.GetDC()
if not dc:
dc = wx.ClientDC(self)
rect = self.GetUpdateRegion().GetBox()
dc.SetClippingRect(rect)
dc.Clear()
bmp = wx.Bitmap("1.jpg")
dc.DrawBitmap(bmp, 0, 0)'''
#wx.StaticText(parent=panel,label='欢迎来到多多瑜教育管理中心',pos=(20,20))
bmp=wx.Image('背景21.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
#self.button = wx.BitmapButton(panel, -1, bmp, pos=(10, 20))
self.buttondancichaxun=wx.Button(panel.bitmap,label='单词查询',pos=(500,250),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttondancichaxun,self.buttondancichaxun)
self.buttondanciluru=wx.Button(parent=panel.bitmap,label='单词录入',pos=(580,250),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttondanciluru,self.buttondanciluru)
self.buttondancixiugai=wx.Button(parent=panel.bitmap,label='单词修改',pos=(660,250),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttondancixiugai,self.buttondancixiugai)
self.buttondancishanchu=wx.Button(parent=panel.bitmap,label='单词删除',pos=(740,250),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttondancishanchu,self.buttondancishanchu)
self.buttonjiansuojilu=wx.Button(parent=panel.bitmap,label='检索记录',pos=(420,370),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonjiansuojilu,self.buttonjiansuojilu)
self.buttondanciceshi=wx.Button(parent=panel.bitmap,label='单词测试',pos=(500,370),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttondanciceshi,self.buttondanciceshi)
self.buttonweizhijiansuo=wx.Button(parent=panel.bitmap,label='位置检索',pos=(420,310),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonweizhijiansuo,self.buttonweizhijiansuo)
self.buttonlijuchaxun=wx.Button(parent=panel.bitmap,label='例句查询',pos=(500,310),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonlijuchaxun,self.buttonlijuchaxun)
self.buttonlijuluru=wx.Button(parent=panel.bitmap,label='例句录入',pos=(580,310),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonlijuluru,self.buttonlijuluru)
self.buttonlijuxiugai=wx.Button(parent=panel.bitmap,label='例句修改',pos=(660,310),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonlijuxiugai,self.buttonlijuxiugai)
self.buttonlijushanchu=wx.Button(parent=panel.bitmap,label='例句删除',pos=(740,310),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonlijushanchu,self.buttonlijushanchu)
self.buttonduanyuchaxun=wx.Button(parent=panel.bitmap,label='短语查询',pos=(580,370),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonduanyuchaxun,self.buttonduanyuchaxun)
self.buttonbeifen=wx.Button(parent=panel.bitmap,label='数据备份',pos=(660,370),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonbeifen,self.buttonbeifen)
self.buttonhuifu=wx.Button(parent=panel.bitmap,label='数据恢复',pos=(740,370),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonhuifu,self.buttonhuifu)
self.buttonwenjianchuangjian=wx.Button(panel.bitmap,label='创建文件',pos=(420,250),size=(70,40))
self.Bind(wx.EVT_BUTTON,self.onbuttonwenjianchuangjian,self.buttonwenjianchuangjian)
def onbuttonbeifen(self,event):
conn=pymysql.connect(host='localhost',user='root',passwd='123456',db='sys')
conn2=pymysql.connect(host='localhost',user='root',passwd='123456',db='sys')
cur=conn.cursor()
cur2=conn2.cursor()
cur2.execute('delete from Wordbeifen')
print('123')
#row=cur.fetchone()
#shuliang=row[0]
cur.execute('select * from Word')
row22=cur.fetchone()
print(row22)
while row22:
cur2.execute('insert into Wordbeifen(danci,fanyi,difficulty) values(%s,%s,%d)',(row22[0],row22[1],row22[2]))
row22=cur.fetchone()
print(row22)
conn.commit()
conn2.commit()
cur.close()
cur2.close()
conn.close()
conn2.close()
beifenframe(None).Show()
def onbuttonhuifu(self,event):
conn=pymysql.connect(host='localhost',user='root',passwd='123456',db='sys')
conn2=pymysql.connect(host='localhost',user='root',passwd='123456',db='sys')
cur=conn.cursor()
cur2=conn2.cursor()
cur2.execute('delete from Word')
print('123')
#row=cur.fetchone()
#shuliang=row[0]
cur.execute('select * from Wordbeifen')
row22=cur.fetchone()
print(row22)
while row22:
cur2.execute('insert into Word(danci,fanyi,difficulty) values(%s,%s,%d)',(row22[0],row22[1],row22[2]))
row22=cur.fetchone()
print(row22)
conn.commit()
conn2.commit()
cur.close()
cur2.close()
conn.close()
conn2.close()
huifuframe(None).Show()
def onbuttondancichaxun(self,event):
dancichaxunframe(None).Show()
def onbuttondanciluru(self,event):
danciluruframe(None).Show()
def onbuttondancixiugai(self,event):
dancixiugaiframe(None).Show()
def onbuttondancishanchu(self,event):
dancishanchuframe(None).Show()
def onbuttondanciceshi(self,event):
danciceshiframe(None).Show()
def onbuttonlijuchaxun(self,event):
lijuchaxunframe(None).Show()
def onbuttonlijuluru(self,event):
lijuluruframe(None).Show()
def onbuttonlijuxiugai(self,event):
lijuxiugaiframe(None).Show()
def onbuttonlijushanchu(self,event):
lijushanchuframe(None).Show()
def onbuttonduanyuchaxun(self,event):
duanyuchaxunframe(None).Show()
def onbuttonwenjianchuangjian(self,event):
wenjianchuangjianframe(None).Show()
def onbuttonweizhijiansuo(self,event):
weizhijiansuoframe(None).Show()
def onbuttonjiansuojilu(self,event):
jiansuojiluframe(None).Show()
class beifenframe(wx.Frame):
def __init__(self,sup):
wx.Frame.__init__(self,parent=sup,title