Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (45 loc) · 1.65 KB
/
Copy pathmain.py
File metadata and controls
58 lines (45 loc) · 1.65 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
import sys,os
from PyQt6.QtWidgets import QApplication, QDialog
from umleditor.mvc_controller.cli_controller import CLI_Controller
from umleditor.mvc_view.gui_view.gui_lambda.GUIV2 import GUIV2
from umleditor.mvc_view.gui_view.gui_cworld.view_GUI import ViewGUI
from umleditor.mvc_controller.gui_controller import ControllerGUI
from umleditor.mvc_controller.GUIV2_controller import ControllerGUI as ControllerGUIV2
from umleditor.mvc_view.gui_view.gui_lambda.dialog_boxes.versionDialog import VersionSelectionDialog
class Command:
def execute(self):
pass
class RunCLICommand(Command):
def __init__(self, cli_app):
self.cli_app = cli_app
def execute(self):
try:
self.cli_app.run()
except KeyboardInterrupt:
pass
except EOFError:
pass
except Exception as e:
print(f"Unexpected Error: {e}")
class RunDebugCLICommand(Command):
def __init__(self, cli_app):
self.cli_app = cli_app
def execute(self):
self.cli_app.run() # Debug mode does not handle exceptions
class RunGUICommand(Command):
def execute(self):
sys.stdout = open(os.devnull, 'w') # Block GUI from printing to the terminal
app = QApplication(sys.argv)
mainWindow = GUIV2()
controller = ControllerGUIV2(mainWindow)
mainWindow.show()
sys.exit(app.exec())
if __name__ == "__main__":
cli_app = CLI_Controller()
commands = {
"cli": RunCLICommand(cli_app),
"debug": RunDebugCLICommand(cli_app),
"gui": RunGUICommand()
}
mode = sys.argv[1] if len(sys.argv) > 1 else "gui"
commands[mode].execute()