import tkinter as tk
from tkinter import font

class CounterApp:
    def __init__(self, root):
        self.root = root
        self.root.title("3x3 Counter Table")

        # 创建 Times New Roman 字体，字号 20
        self.my_font = font.Font(family="Times New Roman", size=20)

        # 存储计数器
        self.counters = {}

        # 构建表格
        self.create_table()

    def create_table(self):
        # 创建 3x3 的格子
        for i in range(3):
            for j in range(3):
                text = ""
                if i == 0 and j == 1:
                    text = "Think Right (TR)"
                elif i == 0 and j == 2:
                    text = "Think Wrong (TW)"
                elif i == 1 and j == 0:
                    text = "Judge Right (JR)"
                elif i == 2 and j == 0:
                    text = "Judge Wrong (JW)"
                elif (i, j) in [(1,1), (1,2), (2,1), (2,2)]:
                    text = "0"
                    self.counters[(i, j)] = 0

                lbl = tk.Label(self.root, text=text, font=self.my_font, width=15, height=3, borderwidth=1, relief="solid")
                lbl.grid(row=i, column=j, padx=2, pady=2, sticky="nsew")

                if (i, j) in self.counters:
                    # 为可点击的格子绑定事件
                    lbl.bind("<Button-1>", lambda e, coord=(i,j), label=lbl: self.increment_counter(coord, label))

    def increment_counter(self, coord, label):
        self.counters[coord] += 1
        label.config(text=str(self.counters[coord]))

if __name__ == "__main__":
    root = tk.Tk()
    app = CounterApp(root)
    root.mainloop()
