-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathapp.py
More file actions
75 lines (60 loc) · 2.33 KB
/
app.py
File metadata and controls
75 lines (60 loc) · 2.33 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import sys
import logging
from dotenv import load_dotenv
from PyQt6.QtWidgets import QApplication, QMessageBox
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon
from forexsmartbot.ui.enhanced_main_window import EnhancedMainWindow
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('forexsmartbot.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
def main():
"""Main entry point for ForexSmartBot."""
try:
load_dotenv()
logger.info("Starting ForexSmartBot application...")
# Create QApplication
app = QApplication(sys.argv)
app.setApplicationName("ForexSmartBot")
app.setApplicationVersion("3.1.0")
app.setOrganizationName("VoxHash")
# Set application properties (PyQt6 compatibility)
try:
app.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
except AttributeError:
pass # Not available in this PyQt6 version
try:
app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps, True)
except AttributeError:
pass # Not available in this PyQt6 version
# Set application icon if available
icon_path = os.path.join(os.path.dirname(__file__), 'assets', 'icons', 'forexsmartbot_256.png')
if os.path.exists(icon_path):
app.setWindowIcon(QIcon(icon_path))
# Create and show main window
window = EnhancedMainWindow()
window.show()
logger.info("Application started successfully")
# Start event loop
sys.exit(app.exec())
except Exception as e:
logger.error(f"Failed to start application: {e}")
# Show error message if QApplication is available
try:
if 'app' in locals():
QMessageBox.critical(None, "Application Error",
f"Failed to start ForexSmartBot:\n\n{str(e)}")
except Exception as display_error:
print(f"Critical error: {e}")
print(f"Failed to display error dialog: {display_error}")
sys.exit(1)
if __name__ == "__main__":
main()