From ea79d0074bbf4285e1b29d389150309a569026a4 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Thu, 4 Apr 2024 22:25:46 -0400 Subject: tk: moved flash_entry to lib, added frame_backgrounds checkbox --- stackrpms_tk_lib.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'stackrpms_tk_lib.py') diff --git a/stackrpms_tk_lib.py b/stackrpms_tk_lib.py index a086344..e106aae 100755 --- a/stackrpms_tk_lib.py +++ b/stackrpms_tk_lib.py @@ -12,6 +12,7 @@ # https://coderslegacy.com/python/create-a-status-bar-in-tkinter/ # https://stackoverflow.com/questions/38329996/enable-mouse-wheel-in-spinbox-tk-python # https://insolor.github.io/effbot-tkinterbook-archive/tkinter-events-and-bindings.htm +# https://stackoverflow.com/questions/27533244/how-to-make-a-flashing-text-box-in-tkinter/78277443#78277443 # Improve: from tkinter import * from tkinter import Spinbox as tkSpinbox, Checkbutton as tkCheckbutton, Entry as tkEntry, Radiobutton as tkRadiobutton @@ -440,3 +441,15 @@ class Radiobutton(tkRadiobutton): if i1 == self.__var.get(): i.focus() break + +def flash_entry(this_entry, colorlist, ms = 1000): + """ + Flash the offending entry box through the colorlist, one color every 'ms' milliseconds. + Example: + flash_entry(entry_that_was_invalid,["red","white"]) + """ + thiscolor = colorlist.pop(0) + this_entry.config(background = thiscolor) + if len(colorlist) > 0: + top = this_entry._nametowidget(this_entry.winfo_parent()) + top.after(ms, lambda te=this_entry, c=colorlist, ms=ms: flash_entry(te,c,ms)) -- cgit