在从0到5的网格列上有六对标签和输入框。但是,在运行代码时,它们之间的间距不是均匀的。有人可以建议解决此问题吗? 谢谢。
from tkinter import *
from tkinter import ttk
def main ():
root = Tk()
root.geometry("1600x800+0+0")
root.configure(bg='Dodgerblue4')
root.grid_rowconfigure(0 , weight=1)
root.grid_columnconfigure(0 , weight=1)
master = Frame(root , bg='Dodgerblue4')
master.pack()
#master.grid(row=0 , column=0 , sticky="nsew")
# ---------------------------------Eye Model-------------------------------------------------------------------------
label_top = Label(master , text="Welcome to the Design Page" , font=('' , '15' , '') ,
bg='Dodgerblue4' , pady=15 , fg='white')
label_top.grid(row=0 , column=2)
# -------------------------------------------------------------------------------------------------------------------
label_corasph = Label(master , text='Cornea Asphericity (Q)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column=0, columnspan=1)
var_corasph = DoubleVar()
entry_corasph = Entry(master , justify=CENTER , textvariable=var_corasph , state='disabled', font=('' , '12' , ''), width=10)
entry_corasph.grid(row= 3 , column=0 , ipady=5)
var_corasph.set(-0.25)
# -----------------------------------------------------------------------------------------------------------------------
label_corrad = Label(master , text='Cornea Radius (mm)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column= 1, columnspan=1)
var_corrad = DoubleVar()
entry_corrad = Entry(master , justify=CENTER , textvariable=var_corrad , state='disabled', font=('' , '12' , ''), width=10)
entry_corrad.grid(row= 3 , column= 1 , ipady=5)
var_corrad.set(7.50)
# ------------------------------------------------------------------------------------------------------------------------
label_sclasph = Label(master , text='Scleral Asphericity (Q)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column= 2, columnspan=1)
var_sclasph = DoubleVar()
entry_sclasph = Entry(master , justify=CENTER , textvariable=var_sclasph, state='disabled', font=('' , '12' , ''), width=10)
entry_sclasph.grid(row= 3 , column= 2 , ipady=5)
var_sclasph.set(-0.05)
# ------------------------------------------------------------------------------------------------------------------------
label_sclrad = Label(master , text='Scleral Radius (mm)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column= 3, columnspan=1)
var_sclrad = DoubleVar()
entry_sclrad = Entry(master , justify=CENTER , textvariable=var_sclrad, state='disabled', font=('' , '12' , ''), width=10)
entry_sclrad.grid(row= 3 , column= 3 , ipady=5)
var_sclrad.set(11.20)
# ------------------------------------------------------------------------------------------------------------------------
label_limbal = Label(master , text='Limbal Semi-Diameter (mm)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column= 4, columnspan=1)
var_limbal = DoubleVar()
entry_limbal = Entry(master , justify=CENTER , textvariable=var_limbal, state='disabled', font=('' , '12' , ''), width=10)
entry_limbal.grid(row= 3 , column= 4 , ipady=5)
var_limbal.set(6.00)
# ------------------------------------------------------------------------------------------------------------------------
label_clearance = Label(master , text='Clearance (mm)' , fg='white' , bg='Dodgerblue4', font=('' , '12' , '')).grid(row= 2 ,
column= 5, columnspan=1)
var_clearance = DoubleVar()
entry_clearance = Entry(master , justify=CENTER , textvariable=var_clearance, state='disabled', font=('' , '12' , ''), width=10)
entry_clearance.grid(row= 3 , column= 5 , ipady=5)
var_clearance.set(0.30)
root.mainloop()
return
if __name__ == '__main__':
main()
答案 0 :(得分:0)
您的标题标签正在加紧间隔。将标题标签的布局更改为此:
label_top.grid(row=0, column=0, columnspan=6)