eric4-trpreviewer.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) 2004 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric4 TR Previewer
9
10 This is the main Python script that performs the necessary initialization
11 of the tr previewer and starts the Qt event loop. This is a standalone version
12 of the integrated tr previewer.
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 from Tools.TRSingleApplication import TRSingleApplicationClient
30 from Utilities import Startup
31
32 def createMainWidget(argv):
33 """
34 Function to create the main widget.
35
36 @param argv list of commandline parameters (list of strings)
37 @return reference to the main widget (QWidget)
38 """
39 from Tools.TRPreviewer import TRPreviewer
40
41 if len(argv) > 1:
42 files = argv[1:]
43 else:
44 files = []
45
46 previewer = TRPreviewer(files, None, 'TRPreviewer')
47 return previewer
48
49 def main():
50 """
51 Main entry point into the application.
52 """
53 options = [\
54 ("--config=configDir",
55 "use the given directory as the one containing the config files"),
56 ]
57 appinfo = Startup.makeAppInfo(sys.argv,
58 "Eric4 TR Previewer",
59 "file",
60 "TR file previewer",
61 options)
62
63 client = TRSingleApplicationClient()
64 res = client.connect()
65 if res > 0:
66 if len(sys.argv) > 1:
67 client.processArgs(sys.argv[1:])
68 sys.exit(0)
69 elif res < 0:
70 print "eric4-trpreviewer: %s" % client.errstr()
71 sys.exit(res)
72 else:
73 res = Startup.simpleAppStartup(sys.argv,
74 appinfo,
75 createMainWidget)
76 sys.exit(res)
77
78 if __name__ == '__main__':
79 main()

eric ide

mercurial