I'm continuing work on a translation/dictionary app to translate English words to my native language. I want to insert a vertical scrollbar on the output widget so that users can scroll up and down to see overflow content. Please, how do I do this? Thanks.
Below is the code:
from tkinter import *
root=Tk()
root.geometry('250x250')
root.configure(background="#35424a")
#Entry widget object
textin = StringVar()
def clk():
entered = ent.get().lower() #get user input and convert to lowercase
output.delete(0.0,END)
if len(entered) > 0:
try:
textin = exlist[entered]
except:
textin = 'Word not found'
output.insert(0.0,textin)
#Entry field
ent=Entry(root,width=15,font=('Times 18'),textvar=textin,bg='white')
ent.place(x=30,y=15)
#Search button
but=Button(root,padx=1,pady=1,text='Translate',command=clk,bg='powder blue',font=('none 18
bold'))
but.place(x=60,y=60)
#output field
output=Text(root,width=15,height=4,font=('Times 18'),fg="black")
output.place(x=30,y=120)
#prevent sizing of window
root.resizable(False,False)
#Dictionary
exlist={
"drum":"drum: (with skin) ŋgɔ̀m; (long, single-headed, skin-covered) ɨbûm ŋgɔ̀m; (with one
end) ŋgɔ̀m ə̀tu",
"bag":"bag: (n) ə̀bàmɨ̀ pl. ɨ̀bàmɨ̀; (assp) (fibre bag) ə̀bàmɨ̀ tɨswé; (a type of bag made of
animal skin) ndoŋ",
"ant":"ant: ɨgwírɨ́ (pl. əgwirɨ); (has a big croup) ɨgwírɨ́ ndiŋ; (ant species, very
small, attack and destroy white ants)"
}
root.mainloop()