src/eric7/eric7_sqlbrowser.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2009 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 eric 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
15 import os
16
17 sys.path.insert(1, os.path.dirname(__file__))
18
19 for arg in sys.argv[:]:
20 if arg.startswith("--config="):
21 import Globals
22 configDir = arg.replace("--config=", "")
23 Globals.setConfigDir(configDir)
24 sys.argv.remove(arg)
25 elif arg.startswith("--settings="):
26 from PyQt6.QtCore import QSettings
27 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
28 if not os.path.isdir(settingsDir):
29 os.makedirs(settingsDir)
30 QSettings.setPath(
31 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir)
32 sys.argv.remove(arg)
33
34 from Globals import AppInfo
35
36 from Toolbox import Startup
37
38
39 def createMainWidget(argv):
40 """
41 Function to create the main widget.
42
43 @param argv list of commandline parameters (list of strings)
44 @return reference to the main widget (QWidget)
45 """
46 from SqlBrowser.SqlBrowser import SqlBrowser
47
48 connections = argv[1:] if len(argv) > 1 else []
49 browser = SqlBrowser(connections)
50
51 return browser
52
53
54 def main():
55 """
56 Main entry point into the application.
57 """
58 from PyQt6.QtGui import QGuiApplication
59 QGuiApplication.setDesktopFileName("eric7_sqlbrowser.desktop")
60
61 options = [
62 ("--config=configDir",
63 "use the given directory as the one containing the config files"),
64 ("--settings=settingsDir",
65 "use the given directory to store the settings files"),
66 ]
67 appinfo = AppInfo.makeAppInfo(sys.argv,
68 "eric SQL Browser",
69 "connection",
70 "SQL browser",
71 options)
72 res = Startup.simpleAppStartup(sys.argv,
73 appinfo,
74 createMainWidget)
75 sys.exit(res)
76
77 if __name__ == '__main__':
78 main()

eric ide

mercurial