def manage_breastfeeding(event, values): now = dtt.datetime.now() is_left = event == 'left' last_entry = get_last_row(Breastfeeding) table_is_empty = Breastfeeding.select().count() == 0 add_new_entry = table_is_empty or not is_breastfeeding() if add_new_entry: # new feed offset = PopupOffsetWindow( 'Άρχισε πριν πόσα λεπτά (αριθμός ή κενό);', 'Σφάλμα στην εισαγωγή, μόνο αριθμούς\n') Breastfeeding(start_time=now - offset, is_left=is_left, used_shield=True) elif is_left == last_entry.is_left: # finish ongoing feed offset = PopupOffsetWindow( 'Σταμάτησε πριν πόσα λεπτά (αριθμός ή κενό);', 'Σφάλμα στην εισαγωγή, μόνο αριθμούς\n') last_entry.end_time = now - offset last_entry.used_shield = sg.PopupYesNo('Προστασία;') comment = sg.PopupGetText('Άλλο σχόλιο;') last_entry.comment = '' if comment is None else comment elif is_left != last_entry.is_left: # cancel ongoing feed if sg.PopupYesNo('Ακύρωση;') == 'Yes': last_entry.delete()
break display_diff = np.argwhere(previous_display != board.display) previous_display = board.display.copy() window.FindElement('remaining').update(mines) for x, y in display_diff: cell_val = board.board[x, y] if cell_val == -1: cell_val = '*' color_update = ('black', 'grey') elif cell_val == 0: cell_val = ' ' color_update = ('white', 'black') else: color_update = ('white', 'black') window.FindElement((x, y)).update(cell_val, button_color=color_update) if game_lost: sleep(3) break if exited: break result = 'NURTZ!' if game_lost else 'HUZZAH!' if sg.PopupYesNo(result + '\nPlay again?') == 'No': break window.close()