when I am adding canvas to my GUI there are appear some weird gaps between buttons.没有画布(红色)时不会出现。
for i in range(1,30):
self.przyciskiZawodnikow.append(Button(root, width=w, text="chuj", compound="bottom", height=h, image=self.obrazy_wlosow['blond'], borderwidth=b, command =lambda i=i: self.aktual_stat(i)))
self.przyciskiZawodnikow[-1].grid(row=0, column=i-1)
self.boisko = Canvas(master, width=200, height=100, background='red')
self.boisko.grid(row=5, sticky='S')
self.boisko = Canvas(master, width=200, height=100, background='red')
self.boisko.grid(row=5, sticky='S')
答案 0 :(得分:0)
您创建一个网格,这意味着一列中的每个单元格都将具有相同的宽度,而一行中的任何单元格都将具有相同的高度。
将画布放在第0列中时(由于未指定该列),这会强制第0列与画布一样宽。由于按钮的宽度不如画布宽,并且您未指定任何其他选项,因此按钮将位于其单元格的中央。因此,任何多余的空间都将在第零列的按钮的每一侧平均分配。