Python Forum

Full Version: Scroll bar height is not fixed with Text widget
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Guys,
Here i am creating a GUI like Search engine.The problem what i am getting is the scroll bar is not fixed with Text widget.Even though i used sticky.

Thanks in advance.


from Tkinter import *
root = Tk()

options = ["10","20","30"]

var = StringVar(root)
var.set('10')

Value = Label(root,text="Value:", font="-weight bold")
Value.grid(row=0,column=0,sticky="W")

Search = Entry(root,width=50)
Search.grid(row=0,column=1)

Top = Label(root,text="TOP",font="-weight bold")
Top.grid(row=0,column=2,sticky="W")

Dropdownlist = OptionMenu(root,var,*options)
Dropdownlist.grid(row=0,column=3,padx=5,sticky="W")

Go = Button(root,text="GO",width=5)
Go.grid(row=0,column=4,sticky="W")

Reset = Button(root,text="RESET",width=5)
Reset.grid(row=0,column=5,padx=5,sticky="W")

Result = Text(root,height=20,width=69)
Result.place(x=10, y=40)

Scroll = Scrollbar(root,command=Result.yview)
Scroll.grid(row=1,column=6,padx=12,sticky='NS')
Result.config(yscrollcommand=Scroll.set)

root.mainloop()
Here's a sample with scrollbar from my thread at https://python-forum.io/Thread-Show-Inst...age-detail
    def create_textframe(self):
        self.textframe = tk.Text(self.fmain, bd=2, bg='#CEF6EC',
                                 relief=tk.RAISED)
        self.txscroll = tk.Scrollbar(self.fmain, orient=tk.VERTICAL,
                                     command=self.textframe.yview)
        self.txscroll.grid(row=1, rowspan=self.treeheight, column=4, sticky='ns')
        self.textframe.configure(yscroll=self.txscroll.set)
        self.textframe.grid(row=0, rowspan=self.treeheight, column=3, padx=2,
                            pady=2, sticky='nsew')
Note that I specify the height (rowspan) to match that of the Text widget
Here i done with (ipady) to fix the scroll bar height.
from Tkinter import *
root = Tk()
 
options = ["10","20","30"]
 
var = StringVar(root)
var.set('10')
 
Value = Label(root,text="Value:", font="-weight bold")
Value.grid(row=0,column=0,sticky="W")
 
Search = Entry(root,width=50)
Search.grid(row=0,column=1)
 
Top = Label(root,text="TOP",font="-weight bold")
Top.grid(row=0,column=2,sticky="W")
 
Dropdownlist = OptionMenu(root,var,*options)
Dropdownlist.grid(row=0,column=3,padx=5,sticky="W")
 
Go = Button(root,text="GO",width=5)
Go.grid(row=0,column=4,sticky="W")
 
Reset = Button(root,text="RESET",width=5)
Reset.grid(row=0,column=5,padx=5,sticky="W")
 
Result = Text(root,height=20,width=69)
Result.grid(rowspan=10,columnspan=40,sticky='W',padx=5)
 
 
Scroll = Scrollbar(root,command=Result.yview)
Scroll.grid(row=1,column=6,ipady=135)
Result.config(yscrollcommand=Scroll.set)
 
root.mainloop()