22 import UI.PixmapCache |
22 import UI.PixmapCache |
23 |
23 |
24 from eric5config import getConfig |
24 from eric5config import getConfig |
25 |
25 |
26 |
26 |
27 def makeAppInfo(argv, name, arg, description, options = []): |
27 def makeAppInfo(argv, name, arg, description, options=[]): |
28 """ |
28 """ |
29 Module function to generate a dictionary describing the application. |
29 Module function to generate a dictionary describing the application. |
30 |
30 |
31 @param argv list of commandline parameters (list of strings) |
31 @param argv list of commandline parameters (list of strings) |
32 @param name name of the application (string) |
32 @param name name of the application (string) |
42 "bin": argv[0], |
42 "bin": argv[0], |
43 "arg": arg, |
43 "arg": arg, |
44 "name": name, |
44 "name": name, |
45 "description": description, |
45 "description": description, |
46 "version": Version, |
46 "version": Version, |
47 "options" : options |
47 "options": options |
48 } |
48 } |
49 |
49 |
50 def usage(appinfo, optlen = 12): |
50 |
|
51 def usage(appinfo, optlen=12): |
51 """ |
52 """ |
52 Module function to show the usage information. |
53 Module function to show the usage information. |
53 |
54 |
54 @param appinfo dictionary describing the application |
55 @param appinfo dictionary describing the application |
55 @param optlen length of the field for the commandline option (integer) |
56 @param optlen length of the field for the commandline option (integer) |
68 Options:""".format(**appinfo)) |
69 Options:""".format(**appinfo)) |
69 for opt in options: |
70 for opt in options: |
70 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1])) |
71 print(" {0} {1}".format(opt[0].ljust(optlen), opt[1])) |
71 sys.exit(0) |
72 sys.exit(0) |
72 |
73 |
|
74 |
73 def version(appinfo): |
75 def version(appinfo): |
74 """ |
76 """ |
75 Module function to show the version information. |
77 Module function to show the version information. |
76 |
78 |
77 @param appinfo dictionary describing the application |
79 @param appinfo dictionary describing the application |
84 Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
86 Copyright (c) 2002 - 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
85 This is free software; see LICENSE.GPL3 for copying conditions. |
87 This is free software; see LICENSE.GPL3 for copying conditions. |
86 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A |
88 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A |
87 PARTICULAR PURPOSE.""".format(**appinfo)) |
89 PARTICULAR PURPOSE.""".format(**appinfo)) |
88 sys.exit(0) |
90 sys.exit(0) |
|
91 |
89 |
92 |
90 def handleArgs(argv, appinfo): |
93 def handleArgs(argv, appinfo): |
91 """ |
94 """ |
92 Module function to handle the always present commandline options. |
95 Module function to handle the always present commandline options. |
93 |
96 |
137 for iconPath in iconPaths: |
142 for iconPath in iconPaths: |
138 if iconPath: |
143 if iconPath: |
139 UI.PixmapCache.addSearchPath(iconPath) |
144 UI.PixmapCache.addSearchPath(iconPath) |
140 if not defaultIconPath in iconPaths: |
145 if not defaultIconPath in iconPaths: |
141 UI.PixmapCache.addSearchPath(defaultIconPath) |
146 UI.PixmapCache.addSearchPath(defaultIconPath) |
|
147 |
142 |
148 |
143 def setLibraryPaths(): |
149 def setLibraryPaths(): |
144 """ |
150 """ |
145 Module function to set the Qt library paths correctly for windows systems. |
151 Module function to set the Qt library paths correctly for windows systems. |
146 """ |
152 """ |
155 QApplication.setLibraryPaths(libraryPaths) |
161 QApplication.setLibraryPaths(libraryPaths) |
156 |
162 |
157 # the translator must not be deleted, therefore we save them here |
163 # the translator must not be deleted, therefore we save them here |
158 loaded_translators = {} |
164 loaded_translators = {} |
159 |
165 |
160 def loadTranslators(qtTransDir, app, translationFiles = ()): |
166 |
|
167 def loadTranslators(qtTransDir, app, translationFiles=()): |
161 """ |
168 """ |
162 Module function to load all required translations. |
169 Module function to load all required translations. |
163 |
170 |
164 @param qtTransDir directory of the Qt translations files (string) |
171 @param qtTransDir directory of the Qt translations files (string) |
165 @param app reference to the application object (QApplication) |
172 @param app reference to the application object (QApplication) |
192 loc = loca |
199 loc = loca |
193 else: |
200 else: |
194 loc = None |
201 loc = None |
195 return loc |
202 return loc |
196 |
203 |
197 def simpleAppStartup(argv, appinfo, mwFactory, quitOnLastWindowClosed = True, |
204 |
198 app = None): |
205 def simpleAppStartup(argv, appinfo, mwFactory, quitOnLastWindowClosed=True, |
|
206 app=None): |
199 """ |
207 """ |
200 Module function to start up an application that doesn't need a specialized start up. |
208 Module function to start up an application that doesn't need a specialized start up. |
201 |
209 |
202 This function is used by all of eric5's helper programs. |
210 This function is used by all of eric5's helper programs. |
203 |
211 |