用户:
lizix查看:0 回复:1 评论:0 创建时间:2023-08-13T11:21:14
【作品展示】

【作品介绍】
哈哈哈哈哈
【作品源代码】
from tkinter import *
from tkinter.ttk import *
from tkinter.font import *
import json
from pyecharts.charts import Radar
import pyecharts.options as opts
def get_question():
'''加载题目'''
with open('question.txt', 'r', encoding='utf-8') as f:
data = f.read()
return json.loads(data)
def test():
'''题目界面'''
global ques
ques = get_question()
global f2,im2,count
if f2:
f2.destroy()
if f1:
f1.destroy()#组件.destroy()移除组件
count+=1
f2 = Canvas(w,width=400,height=581)
im2 = PhotoImage(file='bg2.gif')
f2.create_image(0, 0, image=im2, anchor='nw')#设置对其方式的参数为anchor,左上为‘nw’
f2.create_text(40, 200, text=ques[str(count)]['Q'],fill='white',font=tf,anchor='nw')
f2.pack()
#b_list()
ba = Button(f2, text=ques[str(count)]['A'],command=a)
f2.create_window(120,350, window=ba)
bb = Button(f2, text=ques[str(count)]['B'],command=b)
f2.create_window(300,350, window=bb)
bc = Button(f2, text=ques[str(count)]['C'],command=c)
f2.create_window(120,425, window=bc)
bd = Button(f2, text=ques[str(count)]['D'],command=d)
f2.create_window(300,425, window=bd)
def res():
print('进入结果界面')
print(s,choice)
def a():
global s,choice
choice+='1'
s+=ques[str(count)]['1']+'\n'
if count==5:
res()
else:
test()
def b():
global s,choice
choice+='2'
s+=ques[str(count)]['2']+'\n'
if count==5:
res()
else:
test()
def c():
global s,choice
choice+='3'
s+=ques[str(count)]['3']+'\n'
if count==5:
res()
else:
test()
def d():
global s,choice
choice+='4'
s+=ques[str(count)]['4']+'\n'
if count==5:
res()
else:
test()
def mk_ra():
value=[]
for i in choice:
value.append(int(i))
r=Radar()
schema=[{'name':'乐观','max':4,'min':0},{'name':'善良','max':4,'min':0},{'name':'腹黑','max':4,'min':0},{'name':'幽默','max':4,'min':0},{'name':'创造力','max':4,'min':0}]
#欢迎界面
w = Tk()
count=0
s=''
choice=''
f1 = Canvas(w, width=350, height=530)
f2=None
im1 = PhotoImage(file='bg1.gif')
f1.create_image(-10,-10,image=im1,anchor='nw')
f1.pack()
tf = Font(family='微软雅黑',size=15,weight=BOLD)
f1.create_text(180, 180, text='每个人都有独特的性格特点,\n 快来测测你的性格吧!',font=tf,fill='white')
b1 = Button(f1, text='开始测试', command=test)
f1.create_window(180, 400, window=b1)
print('进入题目界面')
mainloop()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn