tkinter get widget option value

Discussion in 'Python' started by rahulnag22, May 8, 2007.

  1. rahulnag22

    rahulnag22 Guest

    Hi,
    If I have a button widget

    w = Button(root, text = "Button", state = 'disabled')

    How can I get the value of option 'state' from the widget 'w'.
    I want something like --

    print w.state >> to print out >> 'disabled'

    Thanks
    Rahul
     
    rahulnag22, May 8, 2007
    #1
    1. Advertisements

  2. wrote in in
    comp.lang.python:
    print w.cget( "state" )

    Rob.
     
    Rob Williscroft, May 8, 2007
    #2
    1. Advertisements

  3. rahulnag22

    rahulnag22 Guest

    rahulnag22, May 8, 2007
    #3
  4. rahulnag22

    James Stroud Guest

    print w["state"]

    James
     
    James Stroud, May 9, 2007
    #4
  5. rahulnag22

    rahulnag22 Guest


    Thanks! James
     
    rahulnag22, May 9, 2007
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.