Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3355512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:24:15+00:00 2026-05-18T02:24:15+00:00

I have multiple Tkinter listboxes that I have scrolling together using a single scrollbar,

  • 0

I have multiple Tkinter listboxes that I have scrolling together using a single scrollbar, but I’d ALSO like them to scroll together for mousewheel activity over any of the listboxes.

How to do this?

My current code is based on the last pattern discussed here: http://effbot.org/tkinterbook/listbox.htm It works fine when using only the scrollbar, but the listboxes scroll independently when the mousewheel is used.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:24:16+00:00Added an answer on May 18, 2026 at 2:24 am

    Solve the problem pretty much the same way as you did to connect the two widgets to a single scrollbar: create custom bindings for the mousewheel and have those bindings affect both listboxes rather than just one.

    The only real trick is knowing that you get different events for the mousewheel depending on the platform: windows and the Mac gets <MouseWheel> events, linux gets <Button-4> and <Button-5> events.

    Here’s an example, tested on my Mac with python 2.5:

    import Tkinter as tk
    
    class App:
        def __init__(self):
            self.root=tk.Tk()
            self.vsb = tk.Scrollbar(orient="vertical", command=self.OnVsb)
            self.lb1 = tk.Listbox(self.root, yscrollcommand=self.vsb.set)
            self.lb2 = tk.Listbox(self.root, yscrollcommand=self.vsb.set)
            self.vsb.pack(side="right",fill="y")
            self.lb1.pack(side="left",fill="x", expand=True)
            self.lb2.pack(side="left",fill="x", expand=True)
            self.lb1.bind("<MouseWheel>", self.OnMouseWheel)
            self.lb2.bind("<MouseWheel>", self.OnMouseWheel)
            for i in range(100):
                self.lb1.insert("end","item %s" % i)
                self.lb2.insert("end","item %s" % i)
            self.root.mainloop()
    
        def OnVsb(self, *args):
            self.lb1.yview(*args)
            self.lb2.yview(*args)
    
        def OnMouseWheel(self, event):
            self.lb1.yview("scroll", event.delta,"units")
            self.lb2.yview("scroll",event.delta,"units")
            # this prevents default bindings from firing, which
            # would end up scrolling the widget twice
            return "break"
    
    app=App()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple containers like this <div class=container> <span> <!-- Inside the span is
I have multiple lists like below [u'a', 11, u'P'] [u'a', 11, u'A'] [u'b', 2,
I have multiple plone sites in one zope instance (ZODB). Now I'd like to
I have multiple controllers one in Areas /Areas/Demo/Admin/AdminController and other in main site /Controller/Admin/AdminController
I have multiple versions of my website. Each resides in its own folder, for
I have multiple Select statements on my page and the options are all the
I have multiple domains with multiple copies of jQuery.js in separate subfolders. I want
I have multiple TextFiled controls, and can I put a focus on a specific
I have multiple video links from youtube stored in an xml file, I have
I have multiple divs in my page as: <div imageId='image5' name='5' class='speechBubble'> <div imageId='image5'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.