0

Tkinter 上的网格无法正确调整控件的大小。这是我的代码:

menubar = Menu(frm)
txt = Text(frm)
def TxtTupleLineCol():
    str = txt.index(INSERT)
    return tuple(str.split(sep='.'))
scrl = Scrollbar(frm, command=txt.yview)
scrl.grid(column=1, sticky=(E + N + S))
txt.config(yscrollcommand=scrl.set)
txt['wrap'] = WORD
scrlw = Scrollbar(frm, orient=HORIZONTAL, command=txt.xview)
scrlw.grid(row=1, sticky=(S + E + W))
st = StatusBar(frm)
tu  = TxtTupleLineCol()
st.variable.set(('Linha:' + tu[-2] + ' Coluna:' + tu[-1]))
txt.config(xscrollcommand=scrlw.set)
txt.grid(row=0, column=0, sticky=NSEW)
st.grid(row=2, sticky=S + E + W)
filen = Cfg("")
frm.columnconfigure(0, weight=1)
frm.columnconfigure(1, weight=1)
frm.rowconfigure(1,weight=1)
frm.rowconfigure(0, weight=1)
frm.grid_propagate(False)

如果我调整窗口大小,它会在滚动和文本之间留出空间。#FIXME?(在另一部分代码中,我添加了行/列配置。/葡萄牙语不影响理解。)

4

1 回答 1

0

Your code won't run, but judging from what I see it appears you aren't giving your rows or columns any weight, which is usually what causes "doesn't resize properly" problems when using grid. Most likely, adding something like this will fix the problem:

frm.columnconfigure(0, weight=1)
于 2013-10-03T20:00:15.467 回答