diff --git a/ib-clearance.py b/ib-clearance.py index 5f3648e..0aed89e 100755 --- a/ib-clearance.py +++ b/ib-clearance.py @@ -17,6 +17,13 @@ import sqlite3 import time +from os import name + +# Import getch from msvcrt if running on Windows. +if name == "nt": + from msvcrt import getch +else: + from getch import getch def connect_database(file): @@ -145,7 +152,12 @@ def main(): else: print("\nStudent still has lessons, clearance not granted.") - if input("Enter y to run again.") not in ["y", "Y"]: + print("\nPress X key to exit, other key to run again.") + key = getch() + # msvcrt.getch returns type bytes, decode into str. + if isinstance(key, bytes): + key = key.decode() + if key.upper() == "X": break