tkinter get widget option value

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

  1. rahulnag22

    rahulnag22 Guest

    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'

    rahulnag22, May 8, 2007
    1. Advertisements

  2. wrote in in
    print w.cget( "state" )

    Rob Williscroft, May 8, 2007
    1. Advertisements

  3. rahulnag22

    rahulnag22 Guest

    rahulnag22, May 8, 2007
  4. rahulnag22

    James Stroud Guest

    print w["state"]

    James Stroud, May 9, 2007
  5. rahulnag22

    rahulnag22 Guest

    Thanks! James
    rahulnag22, May 9, 2007
    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.