eric6_webbrowser.py

changeset 3669
ac84ac3c0f05
parent 3656
441956d8fce5
child 3670
f0cb7579c0b4
equal deleted inserted replaced
3668:0e83d06e5429 3669:ac84ac3c0f05
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2002 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric5 Web Browser.
9
10 This is the main Python script that performs the necessary initialization
11 of the web browser and starts the Qt event loop. This is a standalone version
12 of the integrated helpviewer.
13 """
14
15 from __future__ import unicode_literals
16 try: # Only for Py2
17 import Utilities.compatibility_fixes # __IGNORE_WARNING__
18 except (ImportError):
19 pass
20
21 try:
22 import sip
23 sip.setdestroyonexit(False)
24 except AttributeError:
25 pass
26
27 import sys
28 import os
29
30 for arg in sys.argv:
31 if arg.startswith("--config="):
32 import Globals
33 configDir = arg.replace("--config=", "")
34 Globals.setConfigDir(configDir)
35 sys.argv.remove(arg)
36 break
37
38 # make ThirdParty package available as a packages repository
39 sys.path.insert(2, os.path.join(os.path.dirname(__file__),
40 "ThirdParty", "Pygments"))
41
42 import Globals
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 Helpviewer.HelpWindow import HelpWindow
56
57 searchWord = None
58 for arg in reversed(argv):
59 if arg.startswith("--search="):
60 searchWord = argv[1].split("=", 1)[1]
61 argv.remove(arg)
62 elif arg.startswith("--"):
63 argv.remove(arg)
64
65 try:
66 home = argv[1]
67 except IndexError:
68 home = ""
69
70 help = HelpWindow(home, '.', None, 'help viewer', searchWord=searchWord)
71 return help
72
73
74 def main():
75 """
76 Main entry point into the application.
77 """
78 options = [
79 ("--config=configDir",
80 "use the given directory as the one containing the config files"),
81 ("--search=word", "search for the given word")
82 ]
83 appinfo = AppInfo.makeAppInfo(sys.argv,
84 "eric5 Web Browser",
85 "file",
86 "web browser",
87 options)
88
89 if not Globals.checkBlacklistedVersions():
90 sys.exit(100)
91
92 res = Startup.simpleAppStartup(sys.argv,
93 appinfo,
94 createMainWidget,
95 installErrorHandler=True)
96 sys.exit(res)
97
98 if __name__ == '__main__':
99 main()

eric ide

mercurial