Using the code found in this stackoverflow post, I have altered it slightly to include a background color for every other checkbutton and set the width to fill up the width of the Text widget. However, when this happens, I can not use my mouse wheel to scroll. I have to grab onto the scroll bar.
Is there a better way to do this that would allow normal scrolling? Here is my code:
import Tkinter as tk
root = tk.Tk()
vsb = tk.Scrollbar(orient="vertical")
text = tk.Text(root, width=40, height=20, yscrollcommand=vsb.set)
vsb.config(command=text.yview)
vsb.pack(side="right",fill="y")
text.pack(side="top",fill="both",expand=True)
for i in range(1000):
bg = 'grey'
if i % 2 == 0:
bg = 'white'
cb = tk.Checkbutton(text="checkbutton #%s" % i, bg=bg, width=35, justify=tk.LEFT)
text.window_create("end", window=cb)
text.insert("end", "\n") # to force one checkbox per line
root.mainloop()