|
1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2017 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 eric Shell. |
|
9 |
|
10 This is the main Python script that performs the necessary initialization |
|
11 of the ShellWindow module and starts the Qt event loop. |
|
12 """ |
|
13 |
|
14 import sys |
|
15 import os |
|
16 |
|
17 originalPathString = os.getenv("PATH") |
|
18 |
|
19 sys.path.insert(1, os.path.dirname(__file__)) |
|
20 |
|
21 for arg in sys.argv[:]: |
|
22 if arg.startswith("--config="): |
|
23 import Globals |
|
24 configDir = arg.replace("--config=", "") |
|
25 Globals.setConfigDir(configDir) |
|
26 sys.argv.remove(arg) |
|
27 elif arg.startswith("--settings="): |
|
28 from PyQt6.QtCore import QSettings |
|
29 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
|
30 if not os.path.isdir(settingsDir): |
|
31 os.makedirs(settingsDir) |
|
32 QSettings.setPath( |
|
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) |
|
34 sys.argv.remove(arg) |
|
35 |
|
36 from Globals import AppInfo |
|
37 |
|
38 from Toolbox import Startup |
|
39 |
|
40 |
|
41 def createMainWidget(argv): |
|
42 """ |
|
43 Function to create the main widget. |
|
44 |
|
45 @param argv list of commandline parameters (list of strings) |
|
46 @return reference to the main widget (QWidget) |
|
47 """ |
|
48 from QScintilla.ShellWindow import ShellWindow |
|
49 |
|
50 return ShellWindow(originalPathString) |
|
51 |
|
52 |
|
53 def main(): |
|
54 """ |
|
55 Main entry point into the application. |
|
56 """ |
|
57 from PyQt6.QtGui import QGuiApplication |
|
58 QGuiApplication.setDesktopFileName("eric7_shell.desktop") |
|
59 |
|
60 options = [ |
|
61 ("--config=configDir", |
|
62 "use the given directory as the one containing the config files"), |
|
63 ("--settings=settingsDir", |
|
64 "use the given directory to store the settings files"), |
|
65 ] |
|
66 appinfo = AppInfo.makeAppInfo(sys.argv, |
|
67 "eric Shell", |
|
68 "", |
|
69 "Stand alone version of the eric" |
|
70 " interpreter shell", |
|
71 options) |
|
72 res = Startup.simpleAppStartup(sys.argv, |
|
73 appinfo, |
|
74 createMainWidget) |
|
75 sys.exit(res) |
|
76 |
|
77 if __name__ == '__main__': |
|
78 main() |