|
1 #!/usr/bin/env python |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 Eric4 SQL Browser |
|
9 |
|
10 This is the main Python script that performs the necessary initialization |
|
11 of the SQL browser and starts the Qt event loop. |
|
12 """ |
|
13 |
|
14 import sys, os |
|
15 import os |
|
16 |
|
17 import sip |
|
18 sip.setapi('QString', 2) |
|
19 |
|
20 for arg in sys.argv: |
|
21 if arg.startswith("--config="): |
|
22 import Utilities |
|
23 configDir = arg.replace("--config=", "") |
|
24 Utilities.setConfigDir(configDir) |
|
25 sys.argv.remove(arg) |
|
26 break |
|
27 |
|
28 from Utilities import Startup |
|
29 |
|
30 def createMainWidget(argv): |
|
31 """ |
|
32 Function to create the main widget. |
|
33 |
|
34 @param argv list of commandline parameters (list of strings) |
|
35 @return reference to the main widget (QWidget) |
|
36 """ |
|
37 from SqlBrowser.SqlBrowser import SqlBrowser |
|
38 |
|
39 if len(argv) > 1: |
|
40 connections = argv[1:] |
|
41 else: |
|
42 connections = [] |
|
43 |
|
44 browser = SqlBrowser(connections) |
|
45 return browser |
|
46 |
|
47 def main(): |
|
48 """ |
|
49 Main entry point into the application. |
|
50 """ |
|
51 options = [\ |
|
52 ("--config=configDir", |
|
53 "use the given directory as the one containing the config files"), |
|
54 ] |
|
55 appinfo = Startup.makeAppInfo(sys.argv, |
|
56 "Eric4 SQL Browser", |
|
57 "connection", |
|
58 "SQL browser", |
|
59 options) |
|
60 res = Startup.simpleAppStartup(sys.argv, |
|
61 appinfo, |
|
62 createMainWidget) |
|
63 sys.exit(res) |
|
64 |
|
65 if __name__ == '__main__': |
|
66 main() |