# -*- coding: utf-8 -*- import tkinter as tk root = tk.Tk() root.title("tk10.py") root.geometry("200x200") ##################################### count = 0 def bClick1(event): # Click mouse left button global count count += 1 lb.config(text = 'Click {} times'.format(count)) def reset(event): # global count count = 0 lb.config(text = 'Click 0 times') btn = tk.Button(root, text = "Click", \ borderwidth = 10, bg = '#0000ff', \ fg = 'yellow') # create a button btn0 = tk.Button(root, text = "Reset", \ borderwidth = 10, bg = '#aaaaff', \ fg = 'brown') # create another button # create a label lb = tk.Label(root, text = 'Click 0 times', fg = 'darkgreen') btn.pack() btn.bind('', bClick1) btn0.pack() btn0.bind('<1>', reset) lb.pack() ##################################### root.mainloop()