1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2007 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 Eric5 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 for arg in sys.argv: |
|
19 if arg.startswith("--config="): |
|
20 import Utilities |
|
21 configDir = arg.replace("--config=", "") |
|
22 Utilities.setConfigDir(configDir) |
|
23 sys.argv.remove(arg) |
|
24 break |
|
25 |
|
26 # make ThirdParty package available as a packages repository |
|
27 try: |
|
28 import pygments # __IGNORE_WARNING__ |
|
29 except ImportError: |
|
30 sys.path.insert(2, os.path.join(os.path.dirname(__file__), "ThirdParty", "Pygments")) |
|
31 |
|
32 from Utilities import Startup |
|
33 |
|
34 |
|
35 def createMainWidget(argv): |
|
36 """ |
|
37 Function to create the main widget. |
|
38 |
|
39 @param argv list of commandline parameters (list of strings) |
|
40 @return reference to the main widget (QWidget) |
|
41 """ |
|
42 from QScintilla.MiniEditor import MiniEditor |
|
43 if len(argv) > 1: |
|
44 return MiniEditor(argv[1]) |
|
45 else: |
|
46 return MiniEditor() |
|
47 |
|
48 def main(): |
|
49 """ |
|
50 Main entry point into the application. |
|
51 """ |
|
52 options = [\ |
|
53 ("--config=configDir", |
|
54 "use the given directory as the one containing the config files"), |
|
55 ("", "name of file to edit") |
|
56 ] |
|
57 appinfo = Startup.makeAppInfo(sys.argv, |
|
58 "Eric5 Editor", |
|
59 "", |
|
60 "Simplified version of the eric5 editor", |
|
61 options) |
|
62 res = Startup.simpleAppStartup(sys.argv, |
|
63 appinfo, |
|
64 createMainWidget) |
|
65 sys.exit(res) |
|
66 |
|
67 if __name__ == '__main__': |
|
68 main() |
|