import tkinter as tk
# 1。新建一个窗口
mywindow = tk.Tk()
# 2.title 开头标题
mywindow.title("阿柱牌计算器")
# 3.设置大小
mywindow.geometry("500x600")
# 创建一个标签
# la = tk.Label(
# mywindow,
# text = "你的电脑中病毒了" ,
# bg = "black", # back ground
# fg = "green", # front ground
# font = (None,130),
# width = 200,
# height =50,
# )
# pack
# l.pack()
a = 1
def num():
global a
a = a+1
l['text'] = '点赞人数:%d'%a
a2 = 0
def num2():
global a2
a2 = a2+1
l2['text'] = '踩人数:%d'%a2
l= tk.Label(
mywindow,
text ='点赞人数:%d'%a,
bg = 'black',
fg = 'yellow',
font = (None,20),
width = 20,
height = 5,
)
l.pack()
l2= tk.Label(
mywindow,
text ='踩人数:%d'%a2,
bg = 'black',
fg = 'yellow',
font = (None,20),
width = 20,
height = 5,
)
l2.pack()
b = tk.Button(
mywindow,
text = "点赞",
font=(None, 20),
width=10,
height=1,
bg='black',
fg='yellow',
command = num
)
b.pack()
c = tk.Button(
mywindow,
text = "踩",
font=(None, 20),
width=10,
height=1,
bg='black',
fg='yellow',
command = num2
)
c.pack()
# 4.进入消息循环
mywindow.mainloop()
harry -学习tkinter
最新推荐文章于 2022-02-08 13:22:37 发布