forked from OthersideAI/self-operating-computer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_main.py
More file actions
105 lines (86 loc) · 3.21 KB
/
gui_main.py
File metadata and controls
105 lines (86 loc) · 3.21 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python
"""
Self-Operating Computer GUI
"""
import sys
import os
import argparse
from PyQt5.QtWidgets import QApplication
# Add the root directory to the system path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Import after setting path
from operate.config import Config
from operate.utils.style import ANSI_BRIGHT_MAGENTA
from gui import SOCChatWindow
def main_entry():
"""
Main entry point for the Self-Operating Computer GUI
"""
parser = argparse.ArgumentParser(
description="Run the Self-Operating Computer GUI with a specified model."
)
parser.add_argument(
"-m",
"--model",
help="Specify the default model to use",
required=False,
default="gpt-4-with-ocr",
)
# Add a flag for verbose mode
parser.add_argument(
"--verbose",
help="Run with verbose logging",
action="store_true",
)
# Allow for dark or light mode
parser.add_argument(
"--light",
help="Use light mode instead of dark mode",
action="store_true",
)
try:
args = parser.parse_args()
# Create Qt application
app = QApplication(sys.argv)
app.setStyle("Fusion")
# Apply dark mode palette unless light mode is requested
if not args.light:
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtCore import Qt
palette = QPalette()
palette.setColor(QPalette.Window, QColor(53, 53, 53))
palette.setColor(QPalette.WindowText, Qt.white)
palette.setColor(QPalette.Base, QColor(25, 25, 25))
palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
palette.setColor(QPalette.ToolTipBase, Qt.white)
palette.setColor(QPalette.ToolTipText, Qt.white)
palette.setColor(QPalette.Text, Qt.white)
palette.setColor(QPalette.Button, QColor(53, 53, 53))
palette.setColor(QPalette.ButtonText, Qt.white)
palette.setColor(QPalette.BrightText, Qt.red)
palette.setColor(QPalette.Link, QColor(42, 130, 218))
palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
palette.setColor(QPalette.HighlightedText, Qt.black)
app.setPalette(palette)
# Initialize configuration
config = Config()
config.verbose = args.verbose
# Create and show the main window
window = SOCChatWindow()
# Set the default model based on command-line argument
model_index = window.model_combo.findText(args.model)
if model_index >= 0:
window.model_combo.setCurrentIndex(model_index)
# Set verbose checkbox based on command-line argument
window.verbose_checkbox.setChecked(args.verbose)
# Show the window
window.show()
# Run the application
sys.exit(app.exec_())
except KeyboardInterrupt:
print(f"\n{ANSI_BRIGHT_MAGENTA}Exiting...")
except Exception as e:
print(f"Error starting GUI: {str(e)}")
sys.exit(1)
if __name__ == "__main__":
main_entry()