host.nfc_tool.main
Entry point for the NFC Battery Tag Tool GUI.
Usage: python -m host.nfc_tool
1"""Entry point for the NFC Battery Tag Tool GUI. 2 3Usage: 4 python -m host.nfc_tool 5""" 6 7import sys 8from pathlib import Path 9 10_HAS_TKINTER = True 11try: 12 import tkinter as _tkinter # noqa: F401 13except ImportError: 14 _HAS_TKINTER = False 15 16 17def _get_project_root(): 18 """Return the project root, handling PyInstaller frozen bundles.""" 19 if getattr(sys, 'frozen', False): 20 return Path(sys._MEIPASS) 21 return Path(__file__).resolve().parent.parent.parent 22 23 24# Ensure project root is importable (for utils.nfc) 25_project_root = _get_project_root() 26if str(_project_root) not in sys.path: 27 sys.path.insert(0, str(_project_root)) 28 29 30def main(): 31 if not _HAS_TKINTER: 32 print( 33 "Error: tkinter is not installed.\n" 34 "On macOS with Homebrew Python, run:\n" 35 " brew install python-tk\n" 36 "Then retry.", 37 file=sys.stderr, 38 ) 39 sys.exit(1) 40 41 from host.nfc_tool.app import NfcToolApp 42 43 app = NfcToolApp(project_root=_project_root) 44 app.mainloop() 45 46 47if __name__ == "__main__": 48 main()
def
main():
31def main(): 32 if not _HAS_TKINTER: 33 print( 34 "Error: tkinter is not installed.\n" 35 "On macOS with Homebrew Python, run:\n" 36 " brew install python-tk\n" 37 "Then retry.", 38 file=sys.stderr, 39 ) 40 sys.exit(1) 41 42 from host.nfc_tool.app import NfcToolApp 43 44 app = NfcToolApp(project_root=_project_root) 45 app.mainloop()