[Tkinter-discuss] Newbie's Scrollbar question

Cam Farnell msa01 at bitflipper.ca
Sun Apr 20 16:10:14 CEST 2008

I had to do this recently where one scroll bar needed to control two canvases. The trick is to create a function which accepts info from the scrollbar and then propagates it to the widgets to be scrolled. Some snippets from my code:

hscroll = Scrollbar(FF,orient=HORIZONTAL,command=Propagator)

def Propagator(*Args):
    Propagate position commands to more than one canvas.
    for C in MyCanvases:

Where "MyCanvases" is a list of the objects (in my case, Canvases) which need to scroll in response to changes in the scroll bar.

Hope this helps


solaris_1234 wrote:
> Is there a way to get a Scrollbar widget to control two widgets?
> I would like to do something like:
> ...
> self.textbox1 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set)
> self.textbox2 = Text(self.myc, yscrollbarcommand=self.scrollbar1.set)
> self.scrollbar1.config(command=self.textbox1.yview)
> self.scrollbar1.config(command=self.textbox2.yview)
> ....
> I understand the second self.scrollbar1.config is the only valid binding 
> for scrollbar1.
> Any hints on how to do this ?
> Thanks,
> tkinter newbie

More information about the Tkinter-discuss mailing list