I am trying to attach a scrollbar to my Text field and have been unable to do so. Here is the segment of code:
self.scroller = Scrollbar(self.root)
self.scroller.place(x=706, y=121)
self.outputArea = Text(self.root, height=26, width=100)
self.outputArea.place(x=0, y=120)
self.scroller.config(command=self.outputArea.yview)
self.outputArea.config(state=DISABLED, yscrollcommand = self.scroller.set)
This code is placing a very small scrollbar right next to my text field (and by very small, I mean that you can see the up and down arrows but nothing in between). I can scroll with it when my text field fills up, but is there a way to at the very least set the height of the scrollbar so that it appears to be the same height as the text field?
Tkinter has three geometry managers: pack, grid, and place.
Pack and grid are usually recommended over place.
You can use the grid manager’s row and column options
to position the Scrollbar next to the Text widget.
Set the Scrollbar widget’s command option to the Text’s yview method.
Set the Text widget’s yscrollcommand option to the Scrollbar’s set method.
Here’s a working example that makes use of ttk:
The part that will address your Scrollbar being small is
sticky='nsew',which you can read about → here.
Something that will be helpful for you to learn right now is that different Tkinter widgets can use different geometry managers within the same program as long as they do not share the same parent.
The tkinter.scrolledtext module contains a class called ScrolledText which is a compound widget (Text & Scrollbar).
The way this is implemented is worth taking a look at.