Tkinter scrollbar and checkbox

Discussion in 'Python' started by goldtech, Apr 24, 2008.

  1. goldtech

    goldtech Guest

    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
     
    goldtech, Apr 24, 2008
    #1
    1. Advertising

  2. On Apr 24, 7:11 am, goldtech <> wrote:
    > 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
     
    Mike Driscoll, Apr 24, 2008
    #2
    1. Advertising

  3. goldtech

    goldtech Guest

    goldtech, Apr 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. codecraig

    Tkinter and Scrollbar

    codecraig, Apr 19, 2005, in forum: Python
    Replies:
    0
    Views:
    359
    codecraig
    Apr 19, 2005
  2. Replies:
    1
    Views:
    989
  3. Dustan

    Tkinter Scrollbar not working

    Dustan, Jan 2, 2006, in forum: Python
    Replies:
    8
    Views:
    573
    Dustan
    Jan 3, 2006
  4. spohle
    Replies:
    1
    Views:
    327
    Simon Forman
    Jun 24, 2006
  5. Alex

    ScrollBar? Does it exist just WEB ScrollBar Control?

    Alex, Apr 1, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    292
    Alvin Bruney [MVP]
    Apr 4, 2004
Loading...

Share This Page