这是我的代码:
from tkinter import *
from tkinter.ttk import *
class App:
def __init__(self, master):
#Frame.__init__(self, master)
fuzz = Entry(master, width = 20).grid(column=2,row=2)
Label (text='Fuzz:').grid(column=1,row=2)
smoothing = Entry(master, width = 20).grid(column=2,row=3,sticky=N)
Label (text='Smoothing:').grid(column=1,row=3,sticky=N)
rendering = Entry(master, width = 20).grid(column=2,row=4,sticky=N)
Label (text='rendering:').grid(column=1,row=4,sticky=N)
colors = Listbox(master, selectmode="extended", activestyle="dotbox")
for item in ["color_1", "color_2", "color_3", "color_4"]:
colors.insert(END, item)
colors.grid(row=3,column=3, columnspan =1, padx=10, rowspan=2)
pics = Listbox(master, selectmode="extended", activestyle="dotbox")
for item in ["pic_1", "pic_2", "pic_3", "pic_4"]:
pics.insert(END, item)
pics.grid(row=3,column=4, columnspan=1, padx=10, rowspan=2)
addcolor = Button(master, text="add color", )
addcolor.grid(column=3,row=1, sticky=W+E, padx=10)
remcolor = Button(master, text="remove color", )
remcolor.grid(column=3,row=2, sticky=W+E, padx=10)
addpic = Button(master, text="add pic", )
addpic.grid(column=4,row=1, sticky=W+E, padx=10)
rempic = Button(master, text="remove pic",)
rempic.grid(column=4,row=2, sticky=W+E, padx=10)
root = Tk()
app = App(root)
root.mainloop()
这就是我想做的:http: //i.imgur.com/sizHT.png
基本上,列表框跨越两行,列表框左侧的两个单元格是列表框高度的一半。但是是否可以让单元格与默认高度一样短?
I have tried:
changing the rowspan to 1
Having the listbox occupy 10 rows (results in odd padding around the cells)