猫史档案馆


【Python作品分享】性格分析器2.0【作业帖】

用户:豁达的玛洛斯ZGvT豁达的玛洛斯ZGvT查看:0 回复:1 评论:0 创建时间:2023-09-23T10:22:53


【作品展示】

center_image

 

【作品介绍】

emm

 

【作品源代码】

from tkinter import*
from tkinter.ttk import*
from tkinter.font import*
import json
root=Tk()
root.title("erererer")
root.geometry("400x572")
a=open('1.txt',"r")
img1=PhotoImage(file="bg1.gif")#获取标签格式图片
f=Canvas(root,width=400,height=572)#创建画布
f.create_image(0,0,image=img1,anchor="nw")#画布上创建图片
tf=Font(family="华文行楷",size=24,weight=BOLD)
tf1=Font(family="华文行楷",size=24,weight=BOLD)
f.create_text(200,200,text="喵李果睿给YOU扯性格",font=tf,fill="white")#画布上创建文字
q_i=1
f2=Canvas(root)
def abc():
    global f,f2,img1,q_i
    a=open('1.txt',"r")
    text=a.read()
    dic=json.loads(text)
    a.close()
    ques=[]
    ans=[]
    if f:
        f.destroy()
    if f2:
        f2.destroy()
    img1=PhotoImage(file="bg2.gif")#获取标签格式图片
    f2=Canvas(root,width=400,height=572)#创建画布
    f2.create_image(0,0,image=img1,anchor="nw")#画布上创建图片
    tf=Font(family="华文行楷",size=10,weight=BOLD)
    tf1=Font(family="华文行楷",size=10,weight=BOLD)
    ques=dic[str(q_i)]
    f2.create_text(200,190,text=ques['Q'],font=tf,fill="blue")
    a=Button(root,text=ques["A"],width=30,command=abc)
    f2.create_window(200,280,window=a)
    b=Button(root,text=ques["B"],width=30,command=abc)
    f2.create_window(200,320,window=b)
    c=Button(root,text=ques["C"],width=30,command=abc)   
    f2.create_window(200,360,window=c)
    d=Button(root,text=ques["D"],width=30,command=abc)
    f2.create_window(200,400,window=d)
    q_i+=1
    f2.pack()

b1=Button(root,text="确定接瘦喵袭击!",command=abc)
f.create_window(200,300,window=b1)
f.pack()#布局管理器
root.mainloop()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
灵秀的蓝甲虫dyCs灵秀的蓝甲虫dyCs

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

 

 

点赞0


评论