基于Python实现的元宵节猜灯谜兑奖软件源码,输入灯谜序号,获取谜面及谜底
核心代码:
import sys
from time import sleep
import xlrd
import os
import tkinter
table_listA = ""
table_listB = ""
filename = os.getcwd()+"\data"
try:
data = xlrd.open_workbook(filename)
table = data.sheets()[0]
except BaseException:
topB = tkinter.Tk()
topB.title("元宵节猜灯谜")
topB.geometry("300x80")
topB.resizable(False, False)
textJ = tkinter.Label(topB, text="未找到数据文件\n\n请将data文件放入同目录下", bd=4,
fg="#10ac84", font=('宋体', 18))
textJ.pack()
topB.mainloop()
# sleep(3)
sys.exit()
top = tkinter.Tk()
top.title("Python代码大全")
top.geometry("300x420")
top.resizable(False, False)
varA = tkinter.StringVar()
varB = tkinter.StringVar()
varA.set(table_listA)
varB.set(table_listB)
textC = tkinter.Label(top, text="\n字 谜 校 对\n", bd=4,
fg="#25ccf7", font=('华文彩云', 20))
rw = tkinter.Entry(top)
bw = tkinter.Button(top, text="输入灯谜序号", command=helloCallBack)
textA = tkinter.Label(top, text="\n谜面", bd=4, fg="#05c46b", font=('黑体', 15))
swA = tkinter.Label(top, textvariable=varA, wraplength=200,
fg="#2c2c54", font=('楷体', 18))
textB = tkinter.Label(top, text="\n谜底", bd=4, fg="#05c46b", font=('黑体', 15))
swB = tkinter.Label(top, textvariable=varB, wraplength=200,
fg="#eb4d4b", font=('楷体', 30))
textC.pack()
rw.pack()
bw.pack()
textA.pack()
swA.pack()
textB.pack()
swB.pack()
top.mainloop()
完整代码下载地址:基于Python实现的元宵节猜灯谜兑奖软件源码