Open
Description
Love your theme.
I need to be able to change the fieldbackground and foreground colors based upon data values. The following code works fine using 'clam' as the theme, but does not work with SV light. Using Fedora Workstation 41 and Gnome Shell 47.4. Any help is appreciated.
import time
import tkinter as tk
import tkinter.ttk as ttk
import sv_ttk
def dosomething():
count = 2
while True:
try:
if count == 1:
entry.configure(style='TEntry')
text = 'Nominal'
count = 2
elif count == 2:
entry.configure(style='Warning.TEntry')
text = 'Warning'
count = 3
elif count == 3:
entry.configure(style='Bad.TEntry')
text = 'Bad'
count = 1
variable.set(text)
entry.update()
time.sleep(2)
except KeyboardInterrupt:
break
# Create Object
root = tk.Tk()
style = ttk.Style()
#sv_ttk.set_theme('light')
style.theme_use('clam')
variable = tk.StringVar(master=root)
style.configure('Warning.TEntry',
fieldbackground = 'yellow',
foreground = 'blue',
based_on = 'TEntry',
)
style.configure('Bad.TEntry',
fieldbackground = 'red',
foreground = 'black',
based_on = 'TEntry',
)
# Add Title
root.title('TEntry Demonstration')
# Add Geometry
root.geometry('500x300')
# Create Label
entry = ttk.Entry(
master = root,
justify = tk.CENTER,
style = 'TEntry',
state = 'readonly',
textvariable = variable,
)
entry.pack(pady=50)
variable.set('Nominal')
root.update
root.after(2000, dosomething)
root.mainloop()
Metadata
Metadata
Assignees
Labels
No labels
Activity