Text绑定上Scrollbar
import tkinter as tk
root = tk.Tk()
root.title('GUI窗口')
root.geometry('500x300+100+100')
# 创建text和scrollbar组件
txt = tk.Text(root, width=68)
txt.pack(side=tk.LEFT, fill=tk.X)
scr = tk.Scrollbar(root)
scr.pack(side=tk.RIGHT, fill=tk.Y)
# 绑定text和scrollbar(以下是关键)
txt["yscrollcommand"] = scr.set
scr["command"] = txt.yview
root.mainloop()