disabledforeground or similar for Entry (in Tkinter)

D

Dustan

Back in this post, I attempted to make a label look like a button:
http://groups.google.com/group/comp...J_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBhouQ

Alright, I've learned my lesson - don't use a new widget; modify the
old one.

Except the Entry widget doesn't have a disabledforeground option.
Neither does the Text widget, but IDLE seems to accomplish making a
disabled Text look the same as an enabled Text in the IDLE Help
section.

No, foreground (fg) and background (bg) don't make a difference; it
still changes the color of the Entry widget upon disabling.

There must be something I'm missing here...
 
D

Dustan

Dustan said:
Back in this post, I attempted to make a label look like a button:
http://groups.google.com/group/comp...J_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBhouQ

Alright, I've learned my lesson - don't use a new widget; modify the
old one.

Except the Entry widget doesn't have a disabledforeground option.
Neither does the Text widget, but IDLE seems to accomplish making a
disabled Text look the same as an enabled Text in the IDLE Help
section.

No, foreground (fg) and background (bg) don't make a difference; it
still changes the color of the Entry widget upon disabling.
There must be something I'm missing here...

Yes there is! I assumed that
http://www.pythonware.com/library/tkinter/introduction/x4447-options.htm
was telling the truth, in that it's not listed there.
 
J

jim-on-linux

Back in this post, I attempted to make a label
look like a button:
http://groups.google.com/group/comp.lang.python
/browse_thread/thread/a83195d3970a6851/2053cbaec
1bc1f19?auth=DQAAAHkAAAAMDAWnhNnzpuKlwOKZUwAGUTt
T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcu
OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2fuL
m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBh
ouQ

Alright, I've learned my lesson - don't use a
new widget; modify the old one.

Except the Entry widget doesn't have a
disabledforeground option. Neither does the
Text widget, but IDLE seems to accomplish
making a disabled Text look the same as an
enabled Text in the IDLE Help section.

No, foreground (fg) and background (bg) don't
make a difference; it still changes the color
of the Entry widget upon disabling.

There must be something I'm missing here...

Have you tried the state option ?

state = 'disabled'

It works for Text, Entry, and Button.

Once disabled you won't be able to make changes
until state= 'normal'

jim-on-linux

http://www.inqvista.com
 
J

jim-on-linux

Back in this post, I attempted to make a label
look like a button:
http://groups.google.com/group/comp.lang.python
/browse_thread/thread/a83195d3970a6851/2053cbaec
1bc1f19?auth=DQAAAHkAAAAMDAWnhNnzpuKlwOKZUwAGUTt
T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcu
OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2fuL
m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBh
ouQ

Alright, I've learned my lesson - don't use a
new widget; modify the old one.

Except the Entry widget doesn't have a
disabledforeground option. Neither does the
Text widget, but IDLE seems to accomplish
making a disabled Text look the same as an
enabled Text in the IDLE Help section.

No, foreground (fg) and background (bg) don't
make a difference; it still changes the color
of the Entry widget upon disabling.

There must be something I'm missing here...

My previous post was hasty and we all know,
"Haste makes waste."

Try this;

If you use wiget-01.pack_forget() or
wiget-01.grid_forget(), you can now build
wiget-02 using wiget-02.pack or grid() for the
same location.

You can reinstall uninstalled wigets by using
pack() or grid() again for those hidden wigets.
However only after uninstalling for the wigets in
those locations.



root = Tk()

test1 = Button(root, text='Test No.1 button', bg =
'yellow', width = 15, height = 10)
test1.grid(row=0, column=0)
test1.grid_forget()


test2 = Button(root, text='Test #2 button', bg =
'green', width = 15, height = 10)
test2.grid(row=0, column=0)

mainloop()


jim-on-linux

http://www.inqvista.com
 
J

jim-on-linux

Since others want to see more,


Try this, you can make the changes you want to the
look of your final output with grid or
pack_forget() .

root = Tk()
class Ktest:
def __init__(self):
self.Ftest1()

def Ftest1(self):
try:
self.test2.grid_forget()
except AttributeError :
pass
self.test1 = Button(root, text='Push #1
button', bg = 'yellow',
width = 25,
command = self.Ftest2,
height = 25)
self.test1.grid(row=0, column=0)


def Ftest2(self):
self.test1.grid_forget()

self.test2 = Button(root, text='Push #2
button', bg = 'green',
width = 25,
command = self.Ftest1,
height = 8)
self.test2.grid(row=0, column=0)
if __name__== '__main__' :
Ktest()
mainloop()


jim-on-linux

http://www.inqvista.com
 

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

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top