tkinter Connecting a vertical scrollbar to a Text widget


Example

The connection between the widget and the scrollbar goes both ways. The scrollbar needs to be expanded vertically so that it has the same height as the widget.

text = tk.Text(parent)
text.pack(side="left")

scroll_y = tk.Scrollbar(parent, orient="vertical", command=text.yview)
scroll_y.pack(side="left", expand=True, fill="y")

text.configure(yscrollcommand=scroll_y.set)