Description
I want to make a GUI using Tkinter / ttk with python, the reason is because I want to learn to style GUI's.
I have tried to find information about how to style the "Entry box" not the background but the actual "insert box" but I cant find any information about how to do this and the built in themes is quite well hidden because I cant find those either..
Image demonstration:
My questions
The standard style applied to ttk.Entry simply doesn't take a fieldbackground option, which would be what changes the colour of the text entry field. The solution is this to create a new element that does respond to the option.
from tkinter import *
from tkinter import ttk
root_window = Tk()
estyle = ttk.Style()
estyle.element_create("plain.field", "from", "clam")
estyle.layout("EntryStyle.TEntry",
[('Entry.plain.field', {'children': [(
'Entry.background', {'children': [(
'Entry.padding', {'children': [(
'Entry.textarea', {'sticky': 'nswe'})],
'sticky': 'nswe'})], 'sticky': 'nswe'})],
'border':'2', 'sticky': 'nswe'})])
estyle.configure("EntryStyle.TEntry",
fieldbackground="light blue") # Set color here
entry = ttk.Entry(root_window, style="EntryStyle.TEntry")
entry.pack(padx=10, pady=10)
root_window.mainloop()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments