我正在用 Python 制作一个简单的 tkinter GUI,我需要放置大约 10 个或更多标签。我使用网格方法放置标签,但在一定数量后出现错误,提示“TypeError:Label object is not callable”。这是标签和网格放置的代码:
UnitPointLabel = ttk.Label(root, text = unit_points)
UnitLabel = ttk.Label(root, text = unit)
HQ1 = ttk.Label(root, text = "HQ:")
HQ2 = ttk.Label(root, text = "HQ:")
Elite1 = ttk.Label(root, text = "Elite:")
Elite2 = ttk.Label(root, text = "Elite:")
Elite3 = ttk.Label(root, text = "Elite:")
Troop1 = ttk.Label(root, text = "Troop:")
Troop2 = ttk.Label(root, text = "Troop:")
Troop3 = ttk.Label(root, text = "Troop:")
Troop4 = ttk.Label(root, text = "Troop:")
Troop5 = ttk.Label(root, text = "Troop:")
Troop6 = ttk.Label(root, text = "Troop:")
Fast_Attack1 = ttk.Label(root, text = "Fast Attack:")
Fast_Attack2 = ttk.Label(root, text = "Fast Attack:")
Heavy_Support1 = ttk.Label(root, text = "Heavy Support:")
Heavy_Support2 = ttk.Label(root, text = "Heavy Support:")
Heavy_Support3 = ttk.Label(root, text = "Heavy Support:")
UnitPointLabel.grid(row = 3, column = 7)
HQ1.grid(row = 3, column = 5)
HQ2.grid(row = 4, column = 5)
Troop1.grid(row = 5, column = 5)
Troop2.grid(row = 6, column = 5)
Troop3.grid(row = 7, column = 5)
Troop4.grid(row = 8, column = 5)
Troop5.grid(row = 9, column = 5)
Troop6.grid(row = 10, column = 5)
Fast_Attack1.grid(row = 11, column = 5)
Fast_Attack2.grid(row = 12, column = 5)
Stops working here: Heavy_Support1(row = 3, column = 6)
Heavy_Support2(row = 2, column = 6)
Heavy_Support3(row = 3, column = 6)
如您所见,我尝试移动行和列,但仍然无法正常工作。有谁知道为什么会这样?