我正在创建一个包含不同行和列的网格视图,主要问题是我的带有文本小部件的滚动条没有显示整个GUI。
我的代码如下:
# -----Zero Row----
lbl = Label(window, font=('Calibri',32), text='Title',bg = '#f0f0f0',bd =10,anchor='w').grid(row=0,columnspan=4)
#---- First Row ---
Label(window, text='Account Number').grid(row =1 , column = 0, sticky='nsew' )
Label(window, text='Balance').grid(row =1 , column = 1, sticky='nsew' )
btnLogOut = Button(window, text='Log Out', command = save_and_logout).grid(row= 1, column= 2, columnspan = 2, sticky='nsew')
#----Second Row----
Label(window, text='ON').grid(row =2 , column = 0, sticky='nsew')
Entry(window, textvariable = account_number_input).grid(row =2 , column = 1, sticky='nsew')
Button(window, text='OF', command = a).grid(row= 2, column= 2, sticky='nsew')
Button(window, text='SWITCH', command = a).grid(row= 2, column= 3, sticky='nsew')
#---Third Row----
text_scrollbar = Scrollbar ( window )
text_scrollbar.pack( side = RIGHT, fill = Y )
transaction_text_widget = Text(window, wrap = NONE, yscrollcommand = text_scrollbar.set)
# state = NORMAL for editing
transaction_text_widget.config(state=NORMAL)
transaction_text_widget.insert("1.0", "text")
transaction_text_widget.insert("1232.30", "text")
transaction_text_widget.insert("132223.0", "text")
# state = DISABLED so that it cannot be edited once written
transaction_text_widget.config(state=DISABLED)
transaction_text_widget.pack(side="left")
#Configure the scrollbars
text_scrollbar.config(command=transaction_text_widget.yview)
transaction_text_widget.grid(row = 3 , column = 1,sticky='nsw')
#-----------setting the column and row weights-----------
window.columnconfigure(0, weight=1)
window.columnconfigure(1, weight=1)
window.columnconfigure(2, weight=1)
window.columnconfigure(3, weight=1)
window.rowconfigure(0, weight =4)
window.rowconfigure(1, weight =2)
window.rowconfigure(2, weight =3)
window.rowconfigure(3, weight =3)
这可能是什么原因?如果我删除第三行部分,则可以看到其他行的GUI。
答案 0 :(得分:0)
我通过添加
修复了它 text_scrollbar.grid(row = 3 , columnspan = 4,sticky='nsew')
感谢您的回答。