How to move the scrollbar to inside the text widget
Cousin Stanley
cousinstanley at gmail.com
Sun Jun 3 10:08:14 EDT 2018
moideen50 at gmail.com wrote:
> I am a Newbie
>
> I have this code
>
> from tkinter import *
>
> root = Tk()
> root.geometry("1200x1000+30+30")
> # width x height + x_offset + y_offset:
> T = Text(root, height=10, width=100)
> T.place(x=20, y=30)
> for i in range(40):
> T.insert(END, "This is line %d\n" % i)
>
> # create a vertical scrollbar to the right of the listbox
> yscroll = Scrollbar(command=T.yview, orient=VERTICAL)
> T.configure(yscrollcommand=yscroll.set)
> yscroll.pack(side="right", fill="y", expand=False)
>
> root.mainloop()
>
>
> The srollbar is on the window frame, is there a way I can move it to inside and right edge of
> text area?
>
> Thanks
You might try the tkinter ScrolledText widget ....
....................................................
from tkinter import *
from tkinter import scrolledtext as ST
root = Tk()
root.geometry( "1200x1000+30+30" ) # width x height + x_offset + y_offset
T = ST.ScrolledText( root, height=40, width=100, font=( 'Fixed' , 14 ) )
T.place( x = 20 , y = 30 )
for i in range( 101 ) :
T.insert( END , " This is line %03d\n" % i )
.....................................
include the rest of your orignal code
.....................................
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list