The question is simple:

I have two scrolled text widgets (I'm using tkinter and python 3.x), and I want to synchronize them, that is I want both scrollbars to move at the same time when the user moves the mouse wheel.

Both widgets are suppossed to contain the same text, and the user is going to compare the information in both, so it is necessary that he can scroll both boxes at once.


Thanks.

Well, I had the same exact problem a few months ago. I used the code found here (link), and found it is pretty good, but not perfect. For example, if you click within one of the listboxes and scroll with the mouse wheel, they do not scroll synchronously. But that's the best I could find. Good luck.

hmmm, how do you use these class guys?

I still do not know object oriente programming, my program is event-oriented.

Can I copy that code and leave it inside a separate file, then import it into my program?

If so, how do I make a widget in my program using that class?

Yes, you should probably just copy that code into a separate file and then import it into your program. From there, you can create the widget in your main script similarly to a normal widget. This example would be some sort of a music player:

import MultiListbox

frame = Frame(root, relief=SUNKEN)
mlb = MultiListbox.MultiListbox(frame, (('Title', 15), ('Artist', 15), ('Length', 12)))
for i in range(1000):
    mlb.insert(END, ('Test Song %d' % i, 'Test Artist %d' % i, 'Length %d' % i))
mlb.pack(expand=YES,fill=BOTH)

Post back if you have any other questions.

This question has already been answered. Start a new discussion instead.