【发布时间】:2018-09-12 21:51:16
【问题描述】:
我已经为一些按钮编写了一些代码。但是,我不确定如何为每个按钮添加特定数量的间距像素。到目前为止是我写的代码。但是,我还没有找到一种可靠的方法来在像素大小的按钮之间添加间距。
import tkinter as tk
#from tkinter import PhotoImage
def banana():
print ("Sundae")
def tomato():
print ("Ketchup")
def potato():
print ("Potato chips")
root = tk.Tk()
root.geometry("960x600")
f1 = tk.Frame(root, width=70, height=30)
f1.grid(row=3, column=0, sticky="we")
button_qwer = tk.Button(f1, text="Banana", command=banana)
button_asdf = tk.Button(f1, text="Tomato", command=tomato)
button_zxcv = tk.Button(f1, text="Potato", command=potato)
button_qwer.grid(row=0, column=0)
button_asdf.grid(row=0, column=1)
button_zxcv.grid(row=0, column=2)
root.mainloop()
【问题讨论】:
标签: python python-3.x tkinter