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()

thats what i have done but my scroll bar is still small

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.

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.

Need help on my tkinter scroll bar please, I have tried everything however I am sure I am not doing something correct. The scroll is not attaching to the listbox , below is the code

from tkinter import *

app = Tk()

label1_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check1', font=('bold',12), pady=10, padx=20)
part_label.grid(row=0, column=0, sticky=W)
label1_entry = Entry(app, textvariable=label1_text)
label1_entry.grid(row=0, column=1)

label2_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check1', font=('bold', 12), pady=7, padx=20)
part_label.grid(row=1, column=0, sticky=W)
label2_entry = Entry(app, textvariable=label2_text)
label2_entry.grid(row=1, column=1)

label3_text = StringVar()
part_label = Label(app, bg='#dfe3ee', text='Check3', font=('bold', 12), pady=20)
part_label.grid(row=0, column=2)
label3_entry = Entry(app, textvariable=label3_text)
label3_entry.grid(row=0, column=3)

label4 = StringVar()
part_label = Label(app, bg='#dfe3ee', text='check4', font=('bold', 12), pady=7)
part_label.grid(row=1, column=2)
label4_entry = Entry(app, textvariable=label4)
label4_entry.grid(row=1, column=3)

B1_btn = Button(app, bg='#cd8de5', text='Button1',font=('bold', 11), width=12)
B1_btn.grid(row=3, column=1, padx=0, pady=5)

B2_btn = Button(app, bg='#cd8de5', text='Button2',font=('bold', 11), width=12 )
B2_btn.grid(row=4, column=1, padx=0, pady=5)

B3_btn = Button(app, bg='#d5a6e6', text='close',font=('bold', 11), width=12)
B3_btn.grid(row=50, column=2, sticky='E')

output_list = Listbox(app, height=20, width=100, border=5)
output_list.grid(row=20, column=0, columnspan=3, rowspan=6, pady=20, padx=20)

scrollbar = Scrollbar(app)
scrollbar.grid(row=20, column =3, rowspan=5, sticky=(N+S))

output_list.configure(yscrollcommand=scrollbar.set)
scrollbar.configure(command=output_list.yview)

app.title('Test Tool')
app.geometry('900x900')
app.configure(bg='#dfe3ee')

app.mainloop()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.