def set_upd_btn(upd): """Set or update selected child's grounded days.""" global last_upd try: int(days_var.get()) except ValueError: # as error: days_var.set(0) if 0 <= int(days_var.get()) <= shrd.MAX_DAYS: childs[childs_combo.get()] = int(days_var.get()) if upd: last_upd = shrd.auto_upd_datafile(childs, last_upd) else: last_upd = dt.date.today() shrd.update_file(childs, last_upd) last_upd_var.set(value=str(last_upd)) else: tk_msg_box.showwarning(lcl.WARNING, lcl.DAYS_RANGE + shrd.MAX_DAYS_STR)
def auto_upd(childs, last_upd): """Automatic update based on current date vs last update date.""" print_state(childs, last_upd) last_upd = shrd.auto_upd_datafile(childs, last_upd) print_state(childs, last_upd)