Tkinter scrollbar and checkbox

G

goldtech

Hi,

I'm stumped on how to have a scrollbar with a long list of checkboxes.
Given code like:

from Tkinter import *
root = Tk()
states = []
for i in range(150):
var = IntVar()
chk = Checkbutton(root, text=str(i), variable=var)
chk.grid(sticky=W)
states.append(var)
root.mainloop()
print map((lambda var: var.get()), states)

I've tried adding this to a frame then adding the frame to a canvas
and it gets complicated rather quickly...

Is there a simple way to add a scroll bar?

Thanks
 
M

Mike Driscoll

Hi,

I'm stumped on how to have a scrollbar with a long list of checkboxes.
Given code like:

from Tkinter import *
root = Tk()
states = []
for i in range(150):
    var = IntVar()
    chk = Checkbutton(root, text=str(i), variable=var)
    chk.grid(sticky=W)
    states.append(var)
root.mainloop()
print map((lambda var: var.get()), states)

I've tried adding this to a frame then adding the frame to a canvas
and it gets complicated rather quickly...

Is there a simple way to add a scroll bar?

Thanks

I use wxPython most of the time, however effbot has a good tutorial on
scrollbars for Tkinter that I think you might find helpful:

http://effbot.org/zone/tkinter-scrollbar-patterns.htm

Here's another link on the subject:

http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm

HTH

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top