a list of Checkbuttons

Discussion in 'Python' started by William Gill, Aug 30, 2005.

  1. William Gill

    William Gill Guest

    OK I'm tired, I've got a cold, and my brain isn't working very well. I
    have a result set ( a tuple of tuples) from a db. Each element has two
    elements; classification number, and classification heading. i.e.
    result=((001,'heading one'),(002,'heading two'),...)

    classification numbers may not be in numerical order, and may skip
    numbers, so they are not good as an index.

    I want to create tkinter Checkbuttons that allow me to select which
    apply to the record I'm editing. What comes to my sub-par mind is to
    create a list and assign Checkbuttons to each element. something like:

    classifications = []
    for count, classification in enumerate(result):
    classifications.append( (IntVar(),classification[0]) )
    Checkbutton(master,
    text=str(classification[0])+': '+classification[1] ,
    variable=classifications[-1]).grid(row=count)



    then to collect which boxes are checked:

    for check in classifications:
    if check[0].get() == 1:
    print 'classification number %s selected" % check[1][0]


    Is this the smartest way to do this? It should work, but will I be able
    to understand this 6 months from now?

    Thanks,

    Bill
     
    William Gill, Aug 30, 2005
    #1
    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. Frank Chen
    Replies:
    3
    Views:
    517
    Cameron Laird
    Oct 8, 2003
  2. valen1260

    putting checkbuttons in a listbox

    valen1260, Dec 20, 2005, in forum: Python
    Replies:
    1
    Views:
    267
    Martin Franklin
    Dec 21, 2005
  3. Lou G

    Checkbuttons in a Text widget

    Lou G, Feb 17, 2006, in forum: Python
    Replies:
    4
    Views:
    322
    Lou G
    Feb 17, 2006
  4. Gigs_
    Replies:
    2
    Views:
    348
    Eric Brunel
    Feb 21, 2007
  5. Joe Van Dyk

    Tkmenubar and checkbuttons

    Joe Van Dyk, May 5, 2005, in forum: Ruby
    Replies:
    4
    Views:
    106
    Joe Van Dyk
    May 5, 2005
Loading...

Share This Page