eric6/eric6_shell.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 6949
a5255f1ba3f0
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric6 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 from __future__ import unicode_literals
15
16 import sys
17 import os
18
19 originalPathString = os.getenv("PATH")
20
21 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
22
23 try: # Only for Py2
24 import Globals.compatibility_fixes # __IGNORE_WARNING__
25 except (ImportError):
26 pass
27
28 for arg in sys.argv[:]:
29 if arg.startswith("--config="):
30 import Globals
31 configDir = arg.replace("--config=", "")
32 Globals.setConfigDir(configDir)
33 sys.argv.remove(arg)
34 elif arg.startswith("--settings="):
35 from PyQt5.QtCore import QSettings
36 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
37 if not os.path.isdir(settingsDir):
38 os.makedirs(settingsDir)
39 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
40 settingsDir)
41 sys.argv.remove(arg)
42
43 from Globals import AppInfo
44
45 from Toolbox import Startup
46
47
48 def createMainWidget(argv):
49 """
50 Function to create the main widget.
51
52 @param argv list of commandline parameters (list of strings)
53 @return reference to the main widget (QWidget)
54 """
55 from QScintilla.ShellWindow import ShellWindow
56
57 return ShellWindow(originalPathString)
58
59
60 def main():
61 """
62 Main entry point into the application.
63 """
64 options = [
65 ("--config=configDir",
66 "use the given directory as the one containing the config files"),
67 ("--settings=settingsDir",
68 "use the given directory to store the settings files"),
69 ]
70 appinfo = AppInfo.makeAppInfo(sys.argv,
71 "Eric6 Shell",
72 "",
73 "Stand alone version of the eric6"
74 " interpreter shell",
75 options)
76 res = Startup.simpleAppStartup(sys.argv,
77 appinfo,
78 createMainWidget)
79 sys.exit(res)
80
81 if __name__ == '__main__':
82 main()

eric ide

mercurial