Hello,
I need your help with something (again):
I need to control two text widgets with one scrollbar and, thanks to this website, I found some code to do it using listboxes (here: http://www.daniweb.com/forums/post940371.html#post940371). I modified it, and it now works with text widgets and pyton 2.x. The problem is: the code is too advanced, and I am unable to implement it within my program... besides, it only works in python 2.x.
I did some research and found out that the reason why it doesn't work with python 3.x is because of the changes in the apply function. So the questions are reduced to just one:
how can I implement the functionality in this code:
from Tkinter import *
root = Tk()
class App:
def __init__(self,master):
scrollbar = Scrollbar(master, orient=VERTICAL)
self.b1 = Text(master, yscrollcommand=scrollbar.set)
self.b2 = Text(master, yscrollcommand=scrollbar.set)
scrollbar.config(command=self.yview)
scrollbar.pack(side=RIGHT, fill=Y)
self.b1.pack(side=LEFT, fill=BOTH, expand=1)
self.b2.pack(side=LEFT, fill=BOTH, expand=1)
def yview(self, *args):
apply(self.b1.yview, args)
apply(self.b2.yview, args)
app = App(root)
for item in range(0,100):
app.b1.insert(1.0,item)
app.b2.insert(1.0,item)
root.mainloop()
into this one:
from tkinter import *
root = Tk()
scrollbar = Scrollbar(root, orient=VERTICAL)
text1 = Text(root, yscrollcommand=scrollbar.set)
text2 = Text(root)
scrollbar.config(command=text1.yview)
text1.grid(row=0, column=1)
text2.grid(row=0, column=2)
scrollbar.grid(row=0, column=3, sticky=N+S)
root.mainloop()
remember that the second code is python3.x code