Deaktivieren Sie die widgets mit dem checkbox"?

Wie kann ich deaktivieren Sie einen Eintrag über eine checkbox " ... ich habe dieses, aber es doens T Arbeit (python 2.7.1)...

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

from Tkinter import *

root = Tk()

class Principal(tk.Tk):
    def __init__(self, *args, **kwargs):

        foo = ""    
        nac = ""

        global ck1
        nac = IntVar()      
        ck1 = Checkbutton(root, text='Test',variable=nac, command=self.naccheck)
        ck1.pack()

        global ent
        ent = Entry(root, width = 20, background = 'white', textvariable = foo, state = DISABLED)       
        ent.pack()

    def naccheck(self):
        if nac == 1:
            ent.configure(state='disabled')
        else:
            ent.configure(state='normal')       

app=Principal()
root.mainloop()
InformationsquelleAutor Hairo | 2011-05-25
Schreibe einen Kommentar