猫史档案馆


【Python作品分享】4-英雄之力-工程包-1【作业帖】

用户:CRONALDOCRONALDO查看:0 回复:0 评论:0 创建时间:2024-03-30T12:04:03


【作品展示】

center_image

 

【作品介绍】

m

 

【作品源代码】

from tkinter import *

# 创建主窗口
root = Tk()
root.title('英雄之力')
root.geometry('460x300+700+300')

hero_list = [['暗裔剑魔', '1.png', 180, 100, 150, 75],
             ['牛头酋长', '2.png', 180, 200, 100, 120],
             ['冰晶凤凰', '3.png', 270, 120, 180, 175],
             ['潮汐海灵', '4.png', 120, 160, 180, 240],
             ['扭曲树精', '5.png', 200, 160, 140, 290],
             ['迷失之牙', '6.png', 220, 160, 180, 190]]

#定义第一个标签
label = Label(root,width=460,height=300)
label.place(x=0,y=0)

#定义第二个标签
text =StringVar()
Label(root,text='请点击按钮',font =('楷体,22'),
     textvariable=text).place(x=50,y=20)

#先设置text
text.set('请点击按钮')

#物理攻击
Label(root,text='物理攻击:',).place(x=50,y=80)

#第一个进度条
canvas_a=Canvas(root,width=300,height=22,bg='white')
canvas_a.place(x=110,y=80)
#魔法防御
Label(root,text='魔法防御:',).place(x=50,y=120)
#防御能力
Label(root,text='防御能力:',).place(x=50,y=160)
#上手难度
Label(root,text='上手难度:',).place(x=50,y=200)

def progress():
    canvas_a.delete('all')
    canvas_b.delete('all')
    canvas_c.delete('all')
    canvas_d.delete('all')
    for i in range(100):
        n_a += 260/100
        n_b += 200/100
        n_c += 180/100
        n_d += 280/100
        canvas_a.create_rectangle(0,0, n_a, 22, width=0, fill='grey')
        canvas_b.create_rectangle(0,0, n_a, 22, width=0, fill='orange')
        canvas_c.create_rectangle(0,0, n_a, 22, width=0, fill='blue')
        canvas_d.create_rectangle(0,0, n_a, 22, width=0, fill='green')
        root.update()
        time.sleep(0.02)
    #hero_data = hero_list[random.randint(0,len(hero_list
    #print(hero_data)
    #text.set(hero_date)
#定义按扭
Button(root,text='查看属性',command=progress).place(x=200,y=240)

root.mainloop()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页