Hey guys,
I am making a calculator program and don't want the user to type directly into the Entry,
so I made the Entry 'readonly'. But that makes it to dark for my liking, so I am trying
to set the readonlybackground='white', but it gives me an error saying that it doesn't
recognize 'readonlybackground'. I am using Python 3.2.0.0, I don't know if that is the reason.

Any ideas?

- WolfShield

Sorry, I forgot to add the code:

dfSV = StringVar()
dsplyF = ttk.Entry(root, text="0.0", textvariable=dfSV, state='readonly', readonlybackground='white')
dfSV.set("")

It also is not letting me do things like 'background', 'foreground', 'bg', or 'fg'.

- WolfShield

Which documents you are using?

According this documentation the key is 'disabledbackground':

disabledbackground=
Background to use when the widget is disabled. If omitted or blank, the standard background is used instead. (disabledBackground/DisabledBackground)

Yep,
That's the documentation I used. 'diabledbackground' is giving an error as well.
I'll post a little more of my code. I am using Tk 8.5

from tkinter import *
from tkinter import ttk
from BK_functions import *

# Create Window
root = Tk()
root.title("Calculator")
root.resizable(0,0)

# Calculator TextField
dfSV = StringVar()
dsplyF = ttk.Entry(root, text="0.0", textvariable=dfSV, state='readonly', disabledbackground='white')
dfSV.set("")

From some docs I am looking at it appears that I may be using ttk::Entry, because that doesn't have a 'background' command, nor any
of the others. What is the difference anyway?

- WolfShield

Why then not use tkinter's Entry.

Why don't you use the Entry widget from tkinter? Module ttk uses Style(), more powerful, but much more complex.

from tkinter import *
from tkinter import ttk
#from BK_functions import *

# Create Window
root = Tk()
root.title("Calculator")
root.resizable(False, False)

# Calculator TextField
dfSV = StringVar()
dsplyF = Entry(root, textvariable=dfSV)
dsplyF.pack()
dsplyF['state'] = 'readonly'
dsplyF['readonlybackground'] = 'yellow'
dfSV.set("1234567890")

root.mainloop()

Awesome!
Thank you guys!

- WolfShield

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.