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
#2
I get errors with your code so can not run it
1) tkinter or tk has not been declared depending on how you import
2) the frame doesn't show up
Reply
#3
(Jun-18-2019, 04:15 PM)woooee Wrote: I get errors with your code so can not run it 1) tkinter or tk has not been declared depending on how you import 2) the frame doesn't show up
Brother this is not the complete code, this is a functionality. You have to add lines to make it work.I need to know how I can have a single scrollbar to move two text area.
Reply
#4
@smabubakkar if you had added a mini-functional example you might get an answer quicker as some folks need to play with it a bit to make sure they are giving the correct answer without that it means they have to spend extra time making their own mini-program to insert your code snippet into and then that does mean that they will do it the same way you did which means again not being able to give a correct answer. So you might want to consider updating your original post with a functioning mini-program that shows what you have.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Help create scrollbar in chatbot with tkinter on python fenec10 4 1,542 Aug-07-2023, 02:59 PM
Last Post: deanhystad
  [Tkinter] Scrollbar apffal 7 3,149 Oct-11-2021, 08:26 PM
Last Post: deanhystad
Question [Tkinter] How to configure scrollbar dimension? water 6 3,460 Jan-03-2021, 06:16 PM
Last Post: deanhystad
  [PyQt] scrollbar in tab issac_n 1 3,614 Aug-04-2020, 01:33 PM
Last Post: deanhystad
  [Tkinter] Scrollbar in tkinter PatrickNoir 2 3,323 Jul-26-2020, 06:02 PM
Last Post: deanhystad
  [Tkinter] Help with Scrollbar JJota 6 3,674 Mar-10-2020, 05:25 AM
Last Post: Larz60+
  [Tkinter] Scrollbar doesn't work on Canvas in Tkinter DeanAseraf1 3 9,380 Sep-19-2019, 03:26 PM
Last Post: joe_momma
  Scrollbar rturus 5 17,451 Jun-06-2019, 01:04 PM
Last Post: heiner55
  [PyGUI] Create a scrollbar in GUI to add test cases mamta_parida 1 3,630 Sep-27-2018, 11:57 AM
Last Post: Larz60+
  [Tkinter] Scrollbar problem & general organization weatherman 13 13,466 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