标签:+= target format import and form window ref 显示
# coding=gbk # window.geometry(‘200x100‘) 是x不是* # 功能:见链接的动态图:https://s1.ax1x.com/2018/04/15/Ce95TI.gif import tkinter window = tkinter.Tk() window.title("jkn1234") window.geometry(‘200x100‘)#是x不是* #var是标签要显示的文字 var = tkinter.StringVar() flag = False count = 0 #f是点击按钮时要执行的函数 def f(): global count, flag if flag == False: count+=1 flag = True var.set("you hit me {}".format(count)) else: count+=1 flag = False var.set("you hit me {}".format(count)) #定义lable标签 lable = tkinter.Label( window, textvariable = var, font=(‘Arial‘, 12),bg = ‘red‘,width=15,height=2 ) lable.pack()# 固定标签位置,不加显示不出来 #定义button按钮 button = tkinter.Button( window, text = "hit me", width = 15, height = 5, command = f # f是点击按钮时要执行的函数 ) button.pack()# 固定标签位置,不加显示不出来 window.mainloop()
标签:+= target format import and form window ref 显示
原文地址:https://www.cnblogs.com/jkn1234/p/8849601.html