![]() |
[Tkinter] Scroll bar height is not fixed with Text widget - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] Scroll bar height is not fixed with Text widget (/thread-1949.html) |
Scroll bar height is not fixed with Text widget - MeeranRizvi - Feb-06-2017 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() RE: Scroll bar height is not fixed with Text widget - Larz60+ - Feb-06-2017 Here's a sample with scrollbar from my thread at https://python-forum.io/Thread-Show-Installed-Package-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 RE: Scroll bar height is not fixed with Text widget - MeeranRizvi - Feb-06-2017 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() |