eric6_shell.py

changeset 5709
f81d0eca2c62
child 5710
b5809b948010
equal deleted inserted replaced
5708:9b01b4004314 5709:f81d0eca2c62
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 ### make ThirdParty package available as a packages repository
42 ##sys.path.insert(2, os.path.join(os.path.dirname(__file__),
43 ## "ThirdParty", "Pygments"))
44
45 from Globals import AppInfo
46
47 from Toolbox import Startup
48
49
50 def createMainWidget(argv):
51 """
52 Function to create the main widget.
53
54 @param argv list of commandline parameters (list of strings)
55 @return reference to the main widget (QWidget)
56 """
57 from QScintilla.ShellWindow import ShellWindow
58
59 return ShellWindow()
60
61
62 def main():
63 """
64 Main entry point into the application.
65 """
66 options = [
67 ("--config=configDir",
68 "use the given directory as the one containing the config files"),
69 ("--settings=settingsDir",
70 "use the given directory to store the settings files"),
71 ]
72 appinfo = AppInfo.makeAppInfo(sys.argv,
73 "Eric6 Shell",
74 "",
75 "Stand alone version of the eric6"
76 " interpreter shell",
77 options)
78 res = Startup.simpleAppStartup(sys.argv,
79 appinfo,
80 createMainWidget)
81 sys.exit(res)
82
83 if __name__ == '__main__':
84 main()

eric ide

mercurial