eric4-editor.py

changeset 0
de9c2efb9d02
child 7
c679fb30c8f3
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric4 Editor
9
10 This is the main Python script that performs the necessary initialization
11 of the MiniEditor module and starts the Qt event loop. This is a standalone
12 version of the integrated MiniEditor module.
13 """
14
15 import sys
16 import os
17
18 import sip
19 sip.setapi("QString", 2)
20
21 for arg in sys.argv:
22 if arg.startswith("--config="):
23 import Utilities
24 configDir = arg.replace("--config=", "")
25 Utilities.setConfigDir(configDir)
26 sys.argv.remove(arg)
27 break
28
29 # make ThirdParty package available as a packages repository
30 try:
31 import pygments
32 except ImportError:
33 sys.path.insert(2, os.path.join(os.path.dirname(__file__), "ThirdParty", "Pygments"))
34
35 from Utilities import Startup
36
37
38 def createMainWidget(argv):
39 """
40 Function to create the main widget.
41
42 @param argv list of commandline parameters (list of strings)
43 @return reference to the main widget (QWidget)
44 """
45 from QScintilla.MiniEditor import MiniEditor
46 if len(argv) > 1:
47 return MiniEditor(argv[1])
48 else:
49 return MiniEditor()
50
51 def main():
52 """
53 Main entry point into the application.
54 """
55 options = [\
56 ("--config=configDir",
57 "use the given directory as the one containing the config files"),
58 ("", "name of file to edit")
59 ]
60 appinfo = Startup.makeAppInfo(sys.argv,
61 "Eric4 Editor",
62 "",
63 "Simplified version of the eric4 editor",
64 options)
65 res = Startup.simpleAppStartup(sys.argv,
66 appinfo,
67 createMainWidget)
68 sys.exit(res)
69
70 if __name__ == '__main__':
71 main()

eric ide

mercurial