Python Forum
[Tkinter] Scroll bar height is not fixed with Text widget
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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()
Reply
#2
Here's a sample with scrollbar from my thread at https://python-forum.io/Thread-Show-Inst...age-detail
1
2
3
4
5
6
7
8
9
    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
Reply
#3
Here i done with (ipady) to fix the scroll bar height.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] alignment ,seems to be a frame in the way [fixed] Hyster 2 874 Nov-02-2024, 09:11 PM
Last Post: Hyster
  [PyQt] QTableView: scroll to top cell of the screen random_nick 2 5,027 Oct-08-2022, 12:29 AM
Last Post: random_nick
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 10,521 Jun-26-2022, 06:26 PM
Last Post: menator01
  [PyQt] How do I get a QScrollArea to scroll? LavaCreeperKing 9 11,678 Oct-29-2021, 08:33 AM
Last Post: Axel_Erfurt
  Tkinter reduce OptionMenu height euras 2 6,433 May-25-2021, 09:14 PM
Last Post: euras
  [Tkinter] Text widget inert mode on and off rfresh737 5 5,630 Apr-19-2021, 02:18 PM
Last Post: joe_momma
  Line numbers in Text widget rfresh737 3 8,033 Apr-15-2021, 12:30 PM
Last Post: rfresh737
  Treeview scroll selected node to top rfresh737 1 3,775 Apr-14-2021, 03:27 AM
Last Post: deanhystad
  [Tkinter] canvas widget scroll issue chrisdb 2 5,626 Apr-07-2021, 05:48 AM
Last Post: chrisdb
  tkinter text widget word wrap position chrisdb 6 10,568 Mar-18-2021, 03:55 PM
Last Post: chrisdb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020