Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Scroll bar height is not fixed with Text widget
#1
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()
Quote
#2
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
Quote
#3
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()


Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Scroll frame with MouseWheel Nemesis 1 101 Mar-25-2020, 09:29 PM
Last Post: Nemesis
  Tkinter - Need Help setting Height of a TextInputBox itslewis 1 99 Mar-22-2020, 02:37 AM
Last Post: deanhystad
  [Tkinter] manipulation of string in Text widget Stauricus 2 168 Feb-17-2020, 09:23 PM
Last Post: Stauricus
  [Kivy] Why I have to click twice to scroll? Hummingbird 0 628 Jan-06-2020, 09:08 PM
Last Post: Hummingbird
  [Tkinter] Paste Operation not working in Text Widget Code_Enthusiast 1 429 Sep-11-2019, 08:49 PM
Last Post: Larz60+
  Require scroll bars horizontal and vertical throughout the window tejgandhi 2 537 Jun-28-2019, 03:13 AM
Last Post: tejgandhi
  [Tkinter] Scroll Bars going backwards goofygoo 2 422 Jun-07-2019, 05:07 PM
Last Post: goofygoo
  how to insert image into Text widget Tkinter atlass218 5 2,972 Apr-17-2019, 05:28 AM
Last Post: atlass218
  [Tkinter] Lock Text Widget height Oxylium 3 650 Feb-14-2019, 10:13 PM
Last Post: woooee
  [Tkinter] update the content of Text widget atlass218 10 6,768 Dec-15-2018, 11:51 AM
Last Post: atlass218

Forum Jump:


Users browsing this thread: 1 Guest(s)