其他分享
首页 > 其他分享> > xinixn -点赞数

xinixn -点赞数

作者:互联网

import tkinter
import time
chuangkou = tkinter.Tk()
chuangkou.geometry("600x1000")
chuangkou.title("maliao")
dian = 0

t1 = time.time()
def xiaochu():
    global dian
    dian = dian +1
    b["text"] = "点赞人数:%d"%dian
    t2 = time.time()
    b2["text"] = "手速:%f"%(dian/(t2-t1))
    b3["text"] = "时间:%f"%(t2-t1)

def newstar():
    global dian
    global t1
    t1 = time.time()
    dian = 0
    b["text"] = "点赞人数:%d"%dian
    b2["text"] = "手速:0"
    b3["text"] = "时间:0"

b = tkinter.Label(
    chuangkou,
    text="点赞人数:%d"%dian,
    bg="#000000",
    fg="#54FF9F",
    width=15,
    height=2,
    font=(None, 30)
)
b.pack()

b2 = tkinter.Label(
    chuangkou,
    text="手速:0",
    bg="#000000",
    fg="#54FF9F",
    width=15,
    height=2,
    font=(None, 30)
)
b2.pack()


b3 = tkinter.Label(
    chuangkou,
    text="时间:0",
    bg="#000000",
    fg="#54FF9F",
    width=15,
    height=2,
    font=(None, 30)
)
b3.pack()

btn = tkinter.Button(
    chuangkou,
    text="点我!!!",
    bg="#6495ED",
    fg="#FA8072",
    font=(None, 30),
    width=30,
    height=8,
    command=xiaochu
)
btn.pack()
gagaga = tkinter.Button(
    chuangkou,
    text="重新开始",
    bg="#6495ED",
    fg="#FA8072",
    font=(None, 30),
    width=20,
    height=8,
    command=newstar
)
gagaga.pack()

def jieqiu():
    # 导入一个专门做游戏的工具包
    import pygame
    import time
    # 1.初始化 timi  loading  初始化  加载中
    pygame.init()
    # 2。设置窗口的大小  screen  屏幕
    # display   dis play 分开玩 ----》展览
    ping_mu = pygame.display.set_mode((600, 500))
    # 3.设置游戏标题
    pygame.display.set_caption("传奇")
    # 小球的x,y坐标
    ballx = 200
    bally = 300
    ball2 = 200
    ball3 = 200
    # 事件,你对电脑进行的任何操作
    while True:
        for event in pygame.event.get():  # for循环是电脑来监测我们的操作
            if event.type == pygame.QUIT:  # 判断是否点了判断按钮
                pygame.quit()  # 如果点了就退出游戏

        # 给屏幕填充颜色 fill
        ping_mu.fill((255, 255, 240))
        # 让小球往右走
        bally = bally + 1
        ball2 = ball2 - 1
        # 判断当小球超过右边窗口,重置ballx位置
        if bally > 500:
            bally = 0
        if ball2 < 0:
            ball2 = 600
        # 画小球 draw  circle
        # 屏幕,颜色,坐标,半径
        pygame.draw.circle(ping_mu, (139, 101, 8), (ballx, bally), 30)
        pygame.draw.circle(ping_mu, (200, 100, 6), (ball2, ball3), 40)
        # update 升级,更新,刷新
        pygame.display.update()
        time.sleep(0.001)



jie = tkinter.Button(
    chuangkou,
    text="接小球游戏",
    bg="#6495ED",
    fg="#FA8072",
    font=(None, 30),
    width=8,
    height=2,
    command=jieqiu
)
jie.pack()




chuangkou.mainloop()
少儿编程侯老师 发布了413 篇原创文章 · 获赞 19 · 访问量 1万+ 私信 关注

标签:dian,tkinter,text,点赞数,chuangkou,pygame,time,xinixn
来源: https://blog.csdn.net/houlaos/article/details/104618210