Home > Software design >  Tkinter scrollbar removes textbox and doesnt sticky to the right
Tkinter scrollbar removes textbox and doesnt sticky to the right

Time:11-18

My textbox spans over 5 rows and 4 columns and I want it to have a scrollbar, so I added one but it removes the textbox and doesn't stick. My textbox looks like this:textbox

and its code like this

 # Textbox

        self.textbox = Text(self)
        self.textbox.grid(row=10, column=1, rowspan=5, columnspan=4, padx=10, pady=10)
        self.vsb = Scrollbar(self.textbox, orient='vertical', command=self.textbox.yview)
        self.vsb.grid(row=10, column=4, rowspan=5, sticky='ns')
        self.textbox.configure(yscrollcommand=self.vsb.set)

after running it my textbox just vanishes textbox vanished

I have no clue what caused this, I usually have no problems with scrollbars.

CodePudding user response:

Maybe you'll have better luck with the ScrolledText widget. See here for docs

from tkinter.scrolledtext import ScrolledText

self.textbox = ScrolledText(self)
  • Related