eric6_shell.py

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

eric ide

mercurial