refactor: Create main.py as entry point, implement on close
This commit creates a dedicated entry point `main.py`, instantiates the application components, and handles the WM_DELETE_WINDOW protocol. - Removed window creation and mainloop from previous file. - Created a dedicated entry point with basic error handling. - Implemented an on_closing protocol to properly close db and exit application - Implemented the loading of database objects.
This commit is contained in:
parent
2c6c55a176
commit
1231673385
2 changed files with 22 additions and 497 deletions
22
main.py
Normal file
22
main.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import sys
|
||||
from database import Database
|
||||
from pdf_exporter import PDFExporter
|
||||
from ui.main_window import MainWindow
|
||||
|
||||
|
||||
def main():
|
||||
db = Database()
|
||||
pdf_exporter = PDFExporter()
|
||||
app = MainWindow(db, pdf_exporter)
|
||||
|
||||
def on_closing():
|
||||
db.close()
|
||||
app.destroy() # Properly destroy the Tkinter window
|
||||
sys.exit()
|
||||
|
||||
app.protocol("WM_DELETE_WINDOW", on_closing) # Handle window closing
|
||||
app.mainloop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue