hi im using tkinter and have a scroll bar that works with my text widget but its so small i dont know why ??

scroll = tkinter.Scrollbar(content,borderwidth=50)
Text = tkinter.Text(content,wrap=CHAR, width=50, height=20)

scroll.config(command=Text.yview)
Text.config(yscrollcommand=scroll.set)

Text.grid(row=2, column=1,columnspan=1, rowspan=3, sticky=(N))
scroll.grid(row=2,column=3)

Hi, I'm pretty new to tkinter as well but you will want to make sure your "content" widget (a frame widget?) is set to expand within it's own container (ie. the root window). When you "grid" the "content" frame put sticky=N+E+W+S so the frame will fill it's container. Then, change your Text.grid line to have sticky=N+E+W+S as well so it will fill the frame. Your scroll bar you will want to put sticky=N+S if it is a vertical scrollbar, or sticky=E+W if it is horizontal. Plus, I made some changes like borderwidth=50 for a scrollbar is HUGE.

from Tkinter import *

root = Tk()

content=Frame(root)
content.grid(sticky=N+E+W+S)

scroll = Scrollbar(content,borderwidth=2)
Text = Text(content,wrap=CHAR, width=50, height=20)
 
scroll.config(command=Text.yview)
Text.config(yscrollcommand=scroll.set)
 
Text.grid(row=0, column=0, sticky=N+E+W+S)
scroll.grid(row=0, column=1, sticky=N+S)

root.mainloop()

Edited 4 Years Ago by NewbieXcellence: n/a

app = Tk()
app.title(" text editor")

content = ttk.Frame(app, padding=(3,3,12,12))
content.grid(column=0, row=0,sticky=(N, S, E, W))

#creat label
labeltext = StringVar()
labeltext.set("enter url:")
label1 = ttk.Label(content, textvariable=labeltext).grid(column=0, row=1, columnspan=1, rowspan=1, sticky=(N, W), padx=5)

#create text box
urlname = StringVar()# text being enterd in tht text box is stored in urlname

urlname_entry = ttk.Entry(content, textvariable=urlname)
urlname_entry.grid(column=1, row=1, columnspan=3,rowspan=5, sticky=(N) )
#focus in the text box so user dont have to click on
urlname_entry.focus()
#create button

button1 = ttk.Button(content,text="get source", command=geturl)
button2 = ttk.Button(content,text="count white spaces", command=count_white_space)
button1.grid(column=3,row=0, columnspan=1, rowspan=2, sticky=(N,W))
button2.grid(column=4,row=0,columnspan=2, rowspan=2, sticky=(N,W))


scroll = tkinter.Scrollbar(content,borderwidth=2)
Text = tkinter.Text(content,wrap=CHAR, width=50, height=20)

scroll.config(command=Text.yview)
Text.config(yscrollcommand=scroll.set)

Text.grid(row=2, column=1,columnspan=1, rowspan=3, sticky=(N))
scroll.grid(row=2,column=3)

app.columnconfigure(0, weight=1)
app.rowconfigure(0, weight=1)
content.columnconfigure(0, weight=3)
content.columnconfigure(1, weight=3)
content.columnconfigure(2, weight=3)
content.columnconfigure(3, weight=1)
content.columnconfigure(4, weight=1)
content.rowconfigure(1, weight=1)




#text = Text(app, width=80,height=40, wrap='none').grid(row=2, column=2)






#adds spacing between widgets
for child in app.winfo_children(): child.grid_configure(padx=5, pady=5)
for child in content.winfo_children(): child.grid_configure(padx=5, pady=5)

app.bind('<Return>',geturl) #enter can also be hit



app.mainloop()

I would guess the problem to be the columnspan or sticky parameters. You can try different combinations of those, but also might want to post to a Tkinter forum like Manning's as many of us use the Pmw extension which has scrollbars built in.

Edited 4 Years Ago by woooee: n/a

the pmw extention doe not realy work form i have trouble installing it on python 3

Your text widget spans 3 rows, your scrollbar does not. Also, you still didn't add sticky N and S to the scroll bar like you say you did after i mentioned it the first time. You need both of those added when you grid the scrollbar and then the scrollbar will be the same height as the text box.

Change the line "scroll.grid(row=2,column=3)" to "scroll.grid(row=2,column=3, rowspan=3, sticky=(N,S))".

It would help people help you if you posted code that could be run without needing to change a bunch of things first like missing functions.

This question has already been answered. Start a new discussion instead.