Matteo Secco
Matteo Secco

Reputation: 633

Let the user see if an entry is disabled in Tkinter

Is there a way to visibly indicate that an Entry is disabled? The only thing that happens when you disable an entry is that you cannot click on it anymore, but its appearance doesn't change.

I tried to change the background to a darker one but it doesn't change if the entry is disabled.

def blockentry(evento):
    if self.addVotoFrameEntry2["state"] == NORMAL:
        self.addVotoFrameEntry2["state"] = DISABLED
    elif self.addVotoFrameEntry2["state"] == DISABLED:
        self.addVotoFrameEntry2["state"] = NORMAL
self.addVotoFrameCheck = Checkbutton(self.addVotoFrame, text="Oggi", font=("Helvetica 11"), variable=var)
self.addVotoFrameCheck.pack(anchor=SW)
self.addVotoFrameCheck.bind("<Button-1>", blockentry)
self.addVotoFrameEntry2 = Entry(self.addVotoFrame, width=10)
self.addVotoFrameEntry2.pack(pady=(0, 10))

Upvotes: 2

Views: 228

Answers (1)

furas
furas

Reputation: 142641

Entry has not only background but also disabledbackground, insertbackground, readonlybackground, selectbackground - so you have to use correct variable :)

See more on Entry

BTW: text color is foreground, disabledforeground, etc.

Upvotes: 2

Related Questions