-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (44 loc) · 1.57 KB
/
Copy pathmain.py
File metadata and controls
52 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from tkinter import *
from ttkthemes import ThemedTk
from gui.gui import GUI
import logging
import sys
from core.error_handler import log_error_with_context
# Configure logging
logging.basicConfig(
filename='PyAutoRaid.log',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
filemode='w',
level=logging.DEBUG
)
logger = logging.getLogger(__name__)
def main():
"""Main application entry point with error handling."""
try:
root = ThemedTk(theme="equilux")
root.geometry("500x560+10+240")
my_gui = GUI(root)
def on_closing():
try:
if hasattr(my_gui, 'timer') and my_gui.timer.is_alive():
my_gui.timer.cancel()
logger.info("Timer cancelled.")
if hasattr(my_gui, 'daily_thread') and my_gui.daily_thread.is_alive():
my_gui.daily_thread.join(timeout=1)
logger.info("Daily thread joined.")
root.destroy()
logger.info("Application closed.")
except Exception as e:
log_error_with_context(e, "application closing")
try:
root.destroy()
except:
pass
root.protocol("WM_DELETE_WINDOW", on_closing) # To ensure clean exit
logger.info("Application started successfully.")
root.mainloop()
except Exception as e:
log_error_with_context(e, "main application startup")
sys.exit(1)
if __name__ == "__main__":
main()