【发布时间】:2022-12-08 20:43:57
【问题描述】:
我正在使用 Tkinter 构建一个 GUI 应用程序。我正在创建 9 个按钮,每行 3 个。我想让它只在它们之间绘制边框,上下没有边框。这可以用 Tkinter 完成吗?
buttons_frame = [tk.Frame(
self.root,
highlightbackground="black",
highlightcolor="black",
highlightthickness=1,
bd=0
) for i in range(9)]
self.field_buttons = [tk.Button(
buttons_frame[i],
width=5,
height=2,
relief='flat',
padx=1,
font=('Arial', 20, 'bold'),
command=lambda x=i: self.push(x)
) for i in range(9)]
row, col = 1, 0
for i in range(9):
buttons_frame[i].grid(row=row, column=col, sticky='news')
self.field_buttons[i].grid(row=row, column=col, sticky='news')
col += 1
if col == 3:
row += 1
col = 0
【问题讨论】:
标签: python tkinter border frame