加了滚动条之前这样
msgs = Listbox(msgf, font=('微软雅黑', 12), relief=FLAT, highlightthickness=0, height=100, width=70)
msgs.grid(row=0, column=0, ipadx=50, ipady=50)
yscrollbar=Scrollbar(msgs,command=msgs.yview)
yscrollbar.pack(side='right', fill='y')
msgs.config(yscrollcommand=yscrollbar.set)
加了之后就这样了
新年快乐🎉,望采纳,谢谢!
可以将listbox的yscrollcommand属性设置为滚动条的set函数,将滚动条的command属性设置为listbox的yview函数,可以解决listbox大小改变的问题。例如:
listbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=listbox.yview)