Python Forum
[Tkinter] Same Scrollbar for two text area
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Same Scrollbar for two text area
#1
Hi,

I have two text area and two separate scroll bar assigned for them. i need a single scrollbar which can scroll both area ? is that possible?? attaching my code below and current UI.


root = tk.Tk()
    textContainer = tk.Frame(root, borderwidth=1, relief="sunken")
    root.title("Comparison")
    #First Text Window
    text = tk.Text(textContainer, width=24, height=13, wrap="none", borderwidth=0)
    textVsb = tk.Scrollbar(textContainer, orient="vertical", command=text.yview)
    textHsb = tk.Scrollbar(textContainer, orient="horizontal", command=text.xview)
    text.configure(yscrollcommand=textVsb.set, xscrollcommand=textHsb.set)
    
    text.insert(tkinter.INSERT,Source_Value)
    text.grid(row=0, column=0, sticky="nsew")
    textVsb.grid(row=0, column=1, sticky="ns")
    textHsb.grid(row=1, column=0, sticky="ew")
    
    #Second Text Window
    text1 = tk.Text(textContainer, width=24, height=13, wrap="none", borderwidth=0)
    text1Vsb = tk.Scrollbar(textContainer, orient="vertical", command=text1.yview)
    text1Hsb = tk.Scrollbar(textContainer, orient="horizontal", command=text1.xview)
    text1.configure(yscrollcommand=text1Vsb.set, xscrollcommand=text1Hsb.set)
    
        
    text1.insert(tkinter.INSERT,Target_Value)
    text1.grid(row=0, column=2, sticky="nsew")
    text1Vsb.grid(row=0, column=3, sticky="ns")
    text1Hsb.grid(row=1, column=2, sticky="ew")
    
    
    textContainer.grid_rowconfigure(0, weight=1)
    textContainer.grid_columnconfigure(0, weight=1)
    textContainer.grid_columnconfigure(2, weight=1)
Reply


Messages In This Thread
Same Scrollbar for two text area - by smabubakkar - Jun-18-2019, 07:16 AM
RE: Same Scrollbar for two text area - by woooee - Jun-18-2019, 04:15 PM
RE: Same Scrollbar for two text area - by Denni - Jun-19-2019, 05:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Help create scrollbar in chatbot with tkinter on python fenec10 4 1,597 Aug-07-2023, 02:59 PM
Last Post: deanhystad
  [Tkinter] Scrollbar apffal 7 3,186 Oct-11-2021, 08:26 PM
Last Post: deanhystad
Question [Tkinter] How to configure scrollbar dimension? water 6 3,530 Jan-03-2021, 06:16 PM
Last Post: deanhystad
  [PyQt] scrollbar in tab issac_n 1 3,642 Aug-04-2020, 01:33 PM
Last Post: deanhystad
  [Tkinter] Scrollbar in tkinter PatrickNoir 2 3,354 Jul-26-2020, 06:02 PM
Last Post: deanhystad
  [Tkinter] Help with Scrollbar JJota 6 3,717 Mar-10-2020, 05:25 AM
Last Post: Larz60+
  [Tkinter] Scrollbar doesn't work on Canvas in Tkinter DeanAseraf1 3 9,424 Sep-19-2019, 03:26 PM
Last Post: joe_momma
  Scrollbar rturus 5 18,194 Jun-06-2019, 01:04 PM
Last Post: heiner55
  [PyGUI] Create a scrollbar in GUI to add test cases mamta_parida 1 3,646 Sep-27-2018, 11:57 AM
Last Post: Larz60+
  [Tkinter] Scrollbar problem & general organization weatherman 13 13,546 Apr-16-2017, 12:55 PM
Last Post: weatherman

Forum Jump:

User Panel Messages

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