Python tkinter布局与按钮间距设置方式
新建label与button,并设置位置(grid)
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text = ‘Label')
label.grid(column = 3, row = 8)
button = tk.Button(root, text = ‘Button')
button.grid(column = 5, row = 1)
按钮间距设置
col_count, row_count = root.grid_size()
for col in xrange(col_count):
root.grid_columnconfigure(col, minsize=20)
for row in xrange(row_count):
root.grid_rowconfigure(row, minsize=20)
补充知识:Python 窗体(tkinter)按钮 位置
我就废话不多说了,还是直接看代码吧
import tkinter
def go(): #函数
print("go函数")
win=tkinter.Tk() #构造窗体
win.title("hello zhaolin")#标题
win.geometry("800x800+300+0")#800宽度,800高度,x,y坐标,左上角
button=tk